Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Local request: all good
if( ! request.remote ) return cb( null, doc );
// Remote request: delete field, and return
delete doc[ 'field3' ];
delete doc[ 'field4' ];
cb( null, doc );
},
});
stores.usersStrategies = new UsersStrategies();
var AuthStrategies = declare( JsonRestStores, JsonRestStores.HTTPMixin, {
schema: new SimpleSchema({
id: { type: 'blob', isRequired: true, trim: 30 } ,
}),
handleGet: true,
handleGetQuery: true,
storeName: 'authStrategies',
//logError: function( error ){ hotCoreServerLogger.log( error ); },
publicURL: '/authstrategies/:id',
hotExpose: true,
implementFetchOne: function( request, cb ){
exports.get = function( done ){
if (!cachedGetResults){
// Simple schema
var BasicSchema = declare( [ SimpleSchema, hotplate.config.get( 'hotplate.SchemaMixin') ] );
// Sets the DB Layer
var DbLayer = declare([ SimpleDbLayer, hotplate.config.get('hotplate.DbLayerMixin') ], {
db: hotplate.config.get( 'hotplate.db' )
});
// Creates a basic DB store based on that layer
var BasicDbStore = declare( [ JsonRestStores, JsonRestStores.SimpleDbLayerMixin, JsonRestStores.HTTPMixin ], {
DbLayer: DbLayer,
chainErrors: 'all'
});
// Legacy names
var HotSchema = BasicSchema;
var HotStore = BasicDbStore;
cachedGetResults = { DbLayer, BasicSchema, HotSchema, BasicDbStore, HotStore }
}
if( done ) return done( null, cachedGetResults );
else return( cachedGetResults );
};
}
self.broadcastStoreChanges( request, m, d[ self.idProperty], d, {}, done );
});
},
});
// Sets the DB Layer
var DbLayer = declare([ SimpleDbLayer, hotplate.config.get('hotplate.DbLayerMixin') ], {
db: hotplate.config.get( 'hotplate.db' )
});
// Creates a basic DB store based on that layer
classes.BasicDbStore = declare( [ JsonRestStores, JsonRestStores.SimpleDbLayerMixin, JsonRestStores.HTTPMixin ], {
DbLayer: DbLayer,
});
// Creates the HotStore: the basic DB store with HotStoreMixin
classes.HotStore = declare( [ classes.BasicDbStore, classes.HotStoreMixin ]);
done( null, classes );
}
});
fromUserId: { type: 'id', searchable: true, required: false },
message: { type: 'serialize', required: true },
added: { type: 'date', searchable: true, default: function() { return new Date() } },
}),
storeName: 'tabMessages',
paramIds: [ 'tabId', 'id' ],
type: 'uncached',
});
stores.tabMessages = new TabMessages();
// NON-DB STORE, sends an object out with all of the messages
// It will return an array of unserialised messages in TabMessages for
// a specific tabId, and then it will DELETE those messages
var TabMessageDispatcher = declare( JsonRestStores, JsonRestStores.HTTPMixin, {
schema: new SimpleSchema({
tabId: { type: 'blob' }, // This is 'blob' as SimpleSchema has numbers for IDs by default
messages: { type: 'none' },
}),
chainErrors: 'all',
storeName: 'tabMessageDispatcher',
publicURL: '/tabs/dispatcher/:tabId',
hotExpose: true,
type: 'uncached',
handleGet: true,
checkPermissions: function( request, method, done ){
// Local request: all good
if( ! request.remote ) return cb( null, doc );
// Remote request: delete field, and return
delete doc[ 'field3' ];
delete doc[ 'field4' ];
cb( null, doc );
},
});
stores.usersStrategies = new UsersStrategies();
var AuthStrategies = declare( JsonRestStores, JsonRestStores.HTTPMixin, {
schema: new SimpleSchema({
id: { type: 'blob', isRequired: true, trim: 30 } ,
}),
handleGet: true,
handleGetQuery: true,
storeName: 'authStrategies',
//logError: function( error ){ hotCoreServerLogger.log( error ); },
publicURL: '/authstrategies/:id',
hotExpose: true,
implementFetchOne: function( request, cb ){
handle: { type: 'string', searchable: true, required: true, trim: 255 },
p1: { type: 'string', searchable: true, required: false, trim: 1024 },
p2: { type: 'string', searchable: true, required: false, trim: 1024 },
p3: { type: 'string', searchable: true, required: false, trim: 1024 },
p4: { type: 'string', searchable: true, required: false, trim: 1024 },
hash: { type: 'string', searchable: true, required: false, trim: 1024 }
}),
paramIds: [ 'id' ],
storeName: 'tabSubscriptions'
})
stores.tabSubscriptions = new TabSubscriptions()
// FINISHED
var UserOnline = declare([JsonRestStores, JsonRestStores.HTTPMixin], {
schema: new HotSchema({
userId: {
type: 'id'
}
}),
handleGet: true,
storeName: 'userOnline',
publicURL: '/userOnline/:userId',
hotExpose: true,
implementFetchOne: function (request, cb) {
var doc;
var docs = [];
for( var strategyId in strategies ){
docs.push( { id: strategyId } );
}
cb( null, docs );
},
});
stores.authStrategies = new AuthStrategies();
// This is used so that an applicaton can know in advance if a user login is already taken
var Logins = declare( JsonRestStores, JsonRestStores.HTTPMixin, {
schema: new SimpleSchema({
login : { type: 'string', required: true, lowercase: true, trim: 30, searchable: true },
}),
storeName: 'logins',
DbLayer: SimpleDbLayer,
handleGetQuery: true,
publicURL: '/logins/:id',
hotExpose: true,
implementQuery: function( request, cb ){
exports.extraStores = function( stores, done ){
// This is used so that an applicaton can know in advance if a user login is already taken
var Logins = declare( JsonRestStores, JsonRestStores.HTTPMixin, {
schema: new SimpleSchema({
login : { type: 'string', required: true, lowercase: true, trim: 30, searchable: true, validator: hotplate.config.get( 'hotCoreAuth.strategies.local.defaultLoginValidator', function(){} ) },
}),
storeName: 'logins',
handleGetQuery: true,
publicURL: '/auth/logins/:id',
hotExpose: true,
// This is descriptive only
queryConditions: {
type: 'eq',
args: [ 'login', '#login' ]