2016-05-06 00:10:55 +00:00
|
|
|
// Copyright IBM Corp. 2014,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
|
|
|
|
|
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')();
|
2014-07-26 17:12:05 +00:00
|
|
|
|
2019-02-05 07:57:18 +00:00
|
|
|
const loopback = require('loopback');
|
|
|
|
const app = loopback();
|
|
|
|
const explorer = require('../');
|
|
|
|
const port = 3000;
|
|
|
|
|
|
|
|
const User = loopback.Model.extend('user', {
|
2014-07-26 17:12:05 +00:00
|
|
|
username: 'string',
|
|
|
|
email: 'string',
|
|
|
|
sensitiveInternalProperty: 'string',
|
2019-02-05 07:57:18 +00:00
|
|
|
}, {hidden: ['sensitiveInternalProperty']});
|
2014-07-26 17:12:05 +00:00
|
|
|
|
|
|
|
User.attachTo(loopback.memory());
|
|
|
|
app.model(User);
|
|
|
|
|
2019-02-05 07:57:18 +00:00
|
|
|
const apiPath = '/api';
|
|
|
|
explorer(app, {basePath: apiPath});
|
2014-07-26 17:12:05 +00:00
|
|
|
app.use(apiPath, loopback.rest());
|
2016-07-27 22:45:24 +00:00
|
|
|
g.log('{{Explorer}} mounted at {{localhost:%s/explorer}}', port);
|
2014-07-26 17:12:05 +00:00
|
|
|
|
|
|
|
app.listen(port);
|