How to use jsonreststores - 8 common examples

To help you get started, we’ve selected a few jsonreststores examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mercmobily / hotplate / _site / hotplate / node_modules / hotCoreAuth / lib / hotCoreAuth.js View on Github external
// 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 ){
github mercmobily / hotplate / core_modules / hotCoreStore / hotCoreStore.js View on Github external
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 );
};
github mercmobily / hotplate / node_modules / hotCoreJsonRestStores / lib / hotCoreJsonRestStores.js View on Github external
}
            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 );

    }
  });
github mercmobily / hotplate / _site / hotplate / node_modules / hotCoreComet / lib / hotCoreComet.js View on Github external
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 ){
github mercmobily / hotplate / core_modules / hotCoreAuth / lib / hotCoreAuth.js View on Github external
// 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 ){
github mercmobily / hotplate / core_modules / hotCoreComet / lib / hotCoreComet.js View on Github external
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) {
github mercmobily / hotplate / _site / hotplate / node_modules / hotCoreAuth / lib / hotCoreAuth.js View on Github external
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 ){
github mercmobily / hotplate / core_modules / hotCoreAuth / lib / auth / local.js View on Github external
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' ]

jsonreststores

A module to create full Json REST stores in minutes

MIT
Latest version published 10 months ago

Package Health Score

50 / 100
Full package analysis