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,
debug: true
});
// 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 ClientService = ds.createModel('ClientService', {});
// Expose to REST
app.model(ClientService);
// LoopBack REST interface
app.use(app.get('restApiRoot'), loopback.rest());
// API explorer (if present)
try {
var explorer = require('loopback-explorer')(app);
app.use('/explorer', explorer);
app.once('started', function (baseUrl) {
console.log('Browse your REST API at %s%s', baseUrl, explorer.route);
});
} catch (e) {
console.log(
'Run `npm install loopback-explorer` to enable the LoopBack explorer'
);
}
//app.use(loopback.urlNotFound());
app.use(loopback.errorHandler());
if (require.main === module) {
app.start();
}
});
app.start = function () {
return app.listen(3000, function () {
app.emit('started', baseUrl);
console.log('LoopBack server listening @ %s%s', baseUrl, '/');
});
};