Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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/}}'));
});
// 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/}}'));
});
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);
});
});
};
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);
});
});
};
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) {