How to use the strong-remoting.SharedClass function in strong-remoting

To help you get started, we’ve selected a few strong-remoting 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 strongloop-community / loopback-sdk-android / test-server / remoting / index.js View on Github external
// Node module: loopback-sdk-android
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

var SG = require('strong-globalize');
var g = SG();
var express = require('express');
var remotes = require('strong-remoting').create();
var SharedClass = require('strong-remoting').SharedClass;

remotes.exports = {
  simple: require('./simple'),
  contract: require('./contract'),
};

remotes.addClass(new SharedClass('SimpleClass', require('./simple-class')));
remotes.addClass(new SharedClass('ContractClass', require('./contract-class')));

var app = express();
app.use(require('morgan')('strong-remoting> :method :url :status'));
app.use(remotes.handler('rest'));

var server = require('http')
  .createServer(app)
  .listen(3001, function() {
    console.log(g.f(
      '{{strong-remoting}} test server listening on {{http://localhost:3001/}}'));
  });
github strongloop-community / loopback-sdk-android / test-server / remoting / index.js View on Github external
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

var SG = require('strong-globalize');
var g = SG();
var express = require('express');
var remotes = require('strong-remoting').create();
var SharedClass = require('strong-remoting').SharedClass;

remotes.exports = {
  simple: require('./simple'),
  contract: require('./contract'),
};

remotes.addClass(new SharedClass('SimpleClass', require('./simple-class')));
remotes.addClass(new SharedClass('ContractClass', require('./contract-class')));

var app = express();
app.use(require('morgan')('strong-remoting> :method :url :status'));
app.use(remotes.handler('rest'));

var server = require('http')
  .createServer(app)
  .listen(3001, function() {
    console.log(g.f(
      '{{strong-remoting}} test server listening on {{http://localhost:3001/}}'));
  });
github strongloop / loopback / lib / model.js View on Github external
description: idDesc},
      // {arg: 'instance', type: 'object', http: {source: 'body'}}
      {arg: 'options', type: 'object', http: createOptionsViaModelMethod},
    ];

    ModelCtor.sharedCtor.http = [
      {path: '/:id'},
    ];

    ModelCtor.sharedCtor.returns = {root: true};

    var remotingOptions = {};
    extend(remotingOptions, options.remoting || {});

    // create a sharedClass
    var sharedClass = ModelCtor.sharedClass = new SharedClass(
      ModelCtor.modelName,
      ModelCtor,
      remotingOptions
    );

    // before remote hook
    ModelCtor.beforeRemote = function(name, fn) {
      var className = this.modelName;
      this._runWhenAttachedToApp(function(app) {
        var remotes = app.remotes();
        remotes.before(className + '.' + name, function(ctx, next) {
          return fn(ctx, ctx.result, next);
        });
      });
    };
github strongloop / loopback / lib / model.js View on Github external
description: idDesc},
      // {arg: 'instance', type: 'object', http: {source: 'body'}}
      {arg: 'options', type: 'object', http: createOptionsViaModelMethod},
    ];

    ModelCtor.sharedCtor.http = [
      {path: '/:id'},
    ];

    ModelCtor.sharedCtor.returns = {root: true};

    const remotingOptions = {};
    extend(remotingOptions, options.remoting || {});

    // create a sharedClass
    const sharedClass = ModelCtor.sharedClass = new SharedClass(
      ModelCtor.modelName,
      ModelCtor,
      remotingOptions,
    );

    // before remote hook
    ModelCtor.beforeRemote = function(name, fn) {
      const className = this.modelName;
      this._runWhenAttachedToApp(function(app) {
        const remotes = app.remotes();
        remotes.before(className + '.' + name, function(ctx, next) {
          return fn(ctx, ctx.result, next);
        });
      });
    };
github ShoppinPal / Materializecss-Autocomplete / node_modules / loopback / lib / model.js View on Github external
description: idDesc},
      // {arg: 'instance', type: 'object', http: {source: 'body'}}
      {arg: 'options', type: 'object', http: createOptionsViaModelMethod},
    ]);

    ModelCtor.sharedCtor.http = [
      {path: '/:id'}
    ];

    ModelCtor.sharedCtor.returns = {root: true};

    var remotingOptions = {};
    extend(remotingOptions, options.remoting || {});

    // create a sharedClass
    var sharedClass = ModelCtor.sharedClass = new SharedClass(
      ModelCtor.modelName,
      ModelCtor,
      remotingOptions
    );

    // setup a remoting type converter for this model
    RemoteObjects.convert(typeName, function(val) {
      return val ? new ModelCtor(val) : val;
    });

    // before remote hook
    ModelCtor.beforeRemote = function(name, fn) {
      var className = this.modelName;
      this._runWhenAttachedToApp(function(app) {
        var remotes = app.remotes();
        remotes.before(className + '.' + name, function(ctx, next) {