2019-05-03 14:28:36 +00:00
|
|
|
// Copyright IBM Corp. 2013,2019. All Rights Reserved.
|
2016-05-06 00:10:55 +00:00
|
|
|
// Node module: loopback-component-explorer
|
|
|
|
// This file is licensed under the MIT License.
|
|
|
|
// License text available at https://opensource.org/licenses/MIT
|
|
|
|
|
2019-02-05 07:57:18 +00:00
|
|
|
'use strict';
|
2016-07-27 22:45:24 +00:00
|
|
|
|
2019-02-05 07:57:18 +00:00
|
|
|
const g = require('strong-globalize')();
|
2013-11-05 19:16:59 +00:00
|
|
|
|
2019-02-05 07:57:18 +00:00
|
|
|
const loopback = require('loopback');
|
|
|
|
const app = loopback();
|
|
|
|
const explorer = require('../');
|
|
|
|
const port = 3000;
|
|
|
|
|
|
|
|
const Product = loopback.PersistedModel.extend('product', {
|
|
|
|
foo: {type: 'string', required: true},
|
2014-07-04 22:09:03 +00:00
|
|
|
bar: 'string',
|
2019-02-05 07:57:18 +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);
|
|
|
|
|
2019-02-05 07:57:18 +00:00
|
|
|
const apiPath = '/api';
|
|
|
|
explorer(app, {basePath: apiPath});
|
2014-07-09 22:38:05 +00:00
|
|
|
app.use(apiPath, loopback.rest());
|
2016-07-27 22:45:24 +00:00
|
|
|
g.log('{{Explorer}} mounted at {{http://localhost:%s/explorer}}', port);
|
2013-11-05 19:16:59 +00:00
|
|
|
|
2014-07-04 19:28:47 +00:00
|
|
|
app.listen(port);
|