2016-05-06 00:10:55 +00:00
|
|
|
// Copyright IBM Corp. 2013,2016. All Rights Reserved.
|
|
|
|
// Node module: loopback-component-explorer
|
|
|
|
// This file is licensed under the MIT License.
|
|
|
|
// License text available at https://opensource.org/licenses/MIT
|
|
|
|
|
2013-11-05 19:16:59 +00:00
|
|
|
var loopback = require('loopback');
|
|
|
|
var app = loopback();
|
|
|
|
var explorer = require('../');
|
2014-07-04 19:28:47 +00:00
|
|
|
var port = 3000;
|
2013-11-05 19:16:59 +00:00
|
|
|
|
2014-10-16 08:17:47 +00:00
|
|
|
var Product = loopback.PersistedModel.extend('product', {
|
2016-04-22 21:09:48 +00:00
|
|
|
foo: { type: 'string', required: true },
|
2014-07-04 22:09:03 +00:00
|
|
|
bar: 'string',
|
2016-04-22 21:09:48 +00:00
|
|
|
aNum: { type: 'number', min: 1, max: 10, required: true, default: 5 },
|
2014-07-04 22:09:03 +00:00
|
|
|
});
|
2013-11-05 19:16:59 +00:00
|
|
|
Product.attachTo(loopback.memory());
|
|
|
|
app.model(Product);
|
|
|
|
|
2014-07-09 22:38:05 +00:00
|
|
|
var apiPath = '/api';
|
2016-05-01 14:39:59 +00:00
|
|
|
explorer(app, { basePath: apiPath });
|
2014-07-09 22:38:05 +00:00
|
|
|
app.use(apiPath, loopback.rest());
|
2014-10-16 08:17:47 +00:00
|
|
|
console.log('Explorer mounted at http://localhost:' + port + '/explorer');
|
2013-11-05 19:16:59 +00:00
|
|
|
|
2014-07-04 19:28:47 +00:00
|
|
|
app.listen(port);
|