Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const jayson = require('jayson');
// create a server
const server = jayson.server({
add: function(args, callback) {
callback(null, args[0] + args[1]);
},
subtract: function(args, callback) {
callback(null, args[0] - args[1]);
},
});
const loopback = require('loopback');
const ds = loopback.createDataSource({
connector: require('../index'),
debug: false,
url: 'http://localhost:3000',
operations: ['add', 'subtract']});
const model = ds.createModel('dummy');
const app = loopback();
app.use(loopback.rest());
app.use(server.middleware(server));
// Bind a http interface to the server and let it listen to localhost:3000
const s = app.listen(3000, function() {
model.add(1, 2, function(err, data) {
console.log(err, data);
var loopback = require('loopback');
var path = require('path');
var app = module.exports = loopback();
app.set('restApiRoot', '/api');
var ds = loopback.createDataSource('soap',
{
connector: require('../index'),
remotingEnabled: true,
// wsdl: 'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL' // The url to WSDL
wsdl: path.join(__dirname, './weather.wsdl')
});
// Unfortunately, the methods from the connector are mixed in asynchronously
// This is a hack to wait for the methods to be injected
ds.once('connected', function () {
// Create the model
var WeatherService = ds.createModel('WeatherService', {});
// Refine the methods
WeatherService.forecast = function (zip, cb) {
// Copyright IBM Corp. 2015. All Rights Reserved.
// Node module: loopback-example-push
var loopback = require('loopback');
var path = require('path');
var app = module.exports = loopback();
// Load up the push data source as the example cannot declaratively define
// the push data source in datasources.json as it cannot resolve the connector
// module by name
var connector = require('loopback-component-push');
app.dataSources.push = loopback.createDataSource("push", {
"defaultForType": "push",
"connector": connector
});
/*
* 1. Configure LoopBack models and datasources
*
* Read more at http://apidocs.strongloop.com/loopback#appbootoptions
*/
app.boot(__dirname);
/*
* 2. Configure request preprocessing
*
* LoopBack support all express-compatible middleware.
var loopback = require('loopback');
var ds = loopback.createDataSource('soap',
{
connector: require('../index'),
wsdl: 'http://www.webservicex.net/stockquote.asmx?WSDL', // The url to WSDL
url: 'http://www.webservicex.net/stockquote.asmx', // The service endpoint
// Map SOAP service/port/operation to Node.js methods
operations: {
// The key is the method name
stockQuote: {
service: 'StockQuote', // The WSDL service name
port: 'StockQuoteSoap', // The WSDL port name
operation: 'GetQuote' // The WSDL operation name
},
// The key is the method name
stockQuote12: {
service: 'StockQuote', // The WSDL service name
function createDataSource(spec, authz) {
return loopback.createDataSource('swagger', {
connector: require('../index'),
spec: spec,
security: authz,
});
}
function createDataSource(spec, options) {
const config = Object.assign({
connector: require('../index'),
spec: spec,
}, options);
return loopback.createDataSource('swagger', config);
}
test.beforeEach(t => {
const app = t.context.app = loopback()
app.set('legacyExplorer', false)
const ds = loopback.createDataSource('memory')
const Post = ds.createModel('post', {title: String})
const Comment = ds.createModel('comment', {title: String})
const Author = ds.createModel('author', {name: String})
app.model(Post)
app.model(Author)
app.model(Comment)
Post.hasMany(Comment)
Post.belongsTo(Author)
Comment.belongsTo(Author)
app.use(loopback.rest())
})
type: 'call',
to: TO,
from: FROM,
url: 'https://raw.githubusercontent.com/dashby3000/loopback-connector-twilio/master/example/call.xml'
};
const emailData = {
type: 'email',
to: TO,
from: FROM,
subject: 'Sending with SendGrid & LoopBack is Fun',
text: 'and easy to do anywhere, even with LoopBack/Node.js',
html: '<strong>and easy to do anywhere, even with LoopBack/Node.js</strong>',
};
var ds = require('loopback').createDataSource({connector: require('../'), accountSid: SID, authToken: TOKEN, sgAPIKey: SGAPIKEY});
var Twilio = ds.createModel('twilio', {
type: {type: String, id: true, required: true},
to: {type: String, required: true},
from: {type: String, required: true},
body: {type: String, required: true},
url: {type: String, required: true}
});
Twilio.send(smsData, function (err, data) {
if (err) {
console.log(err);
} else {
console.log(data);
}
});
DataSourceDefinition.prototype.toDataSource = function() {
return loopback.createDataSource(this.name, this);
};
var loopback = require("loopback");
var ds = loopback.createDataSource({
connector: require("../index"),
strictSSL: false,
debug: false,
defaults: {
"headers": {
"accept": "application/json",
"content-type": "application/json"
}
},
operations: [
{
template: {
"method": "GET",
"url": "http://maps.googleapis.com/maps/api/geocode/{format=json}",
"query": {
"address": "{street},{city},{zipcode}",