UNPKG

800 BJavaScriptView Raw
1// Copyright IBM Corp. 2013,2016. All Rights Reserved.
2// Node module: loopback-component-explorer
3// This file is licensed under the MIT License.
4// License text available at https://opensource.org/licenses/MIT
5
6var g = require('strong-globalize')();
7
8var loopback = require('loopback');
9var app = loopback();
10var explorer = require('../');
11var port = 3000;
12
13var 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});
18Product.attachTo(loopback.memory());
19app.model(Product);
20
21var apiPath = '/api';
22explorer(app, { basePath: apiPath });
23app.use(apiPath, loopback.rest());
24g.log('{{Explorer}} mounted at {{http://localhost:%s/explorer}}', port);
25
26app.listen(port);