loopback-component-explorer/example/simple.js

20 lines
549 B
JavaScript
Raw Normal View History

2013-11-05 19:16:59 +00:00
var loopback = require('loopback');
var app = loopback();
var explorer = require('../');
var port = 3000;
2013-11-05 19:16:59 +00:00
var Product = loopback.PersistedModel.extend('product', {
2016-04-22 21:09:48 +00:00
foo: { type: 'string', required: true },
bar: 'string',
2016-04-22 21:09:48 +00:00
aNum: { type: 'number', min: 1, max: 10, required: true, default: 5 },
});
2013-11-05 19:16:59 +00:00
Product.attachTo(loopback.memory());
app.model(Product);
var apiPath = '/api';
explorer(app, { basePath: apiPath });
app.use(apiPath, loopback.rest());
console.log('Explorer mounted at http://localhost:' + port + '/explorer');
2013-11-05 19:16:59 +00:00
app.listen(port);