1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var g = require('strong-globalize')();
|
7 |
|
8 | var loopback = require('loopback');
|
9 | var app = loopback();
|
10 | var explorer = require('../');
|
11 | var port = 3000;
|
12 |
|
13 | var Product = loopback.PersistedModel.extend('product', {
|
14 | foo: { type: 'string', required: true },
|
15 | bar: 'string',
|
16 | aNum: { type: 'number', min: 1, max: 10, required: true, default: 5 },
|
17 | });
|
18 | Product.attachTo(loopback.memory());
|
19 | app.model(Product);
|
20 |
|
21 | var apiPath = '/api';
|
22 | explorer(app, { basePath: apiPath });
|
23 | app.use(apiPath, loopback.rest());
|
24 | g.log('{{Explorer}} mounted at {{http://localhost:%s/explorer}}', port);
|
25 |
|
26 | app.listen(port);
|