2018-03-29 16:43:30 +03:00
|
|
|
const Main = require('apr-main');
|
|
|
|
const Nav = require('hapi-webconsole-nav');
|
|
|
|
const Url = require('url');
|
2018-05-07 15:33:08 +03:00
|
|
|
|
2018-03-29 16:43:30 +03:00
|
|
|
const Server = require('./server');
|
2018-05-07 15:33:08 +03:00
|
|
|
const Ui = require('my-joy-navigation');
|
2018-03-29 16:43:30 +03:00
|
|
|
|
|
|
|
const Regions = require('../data/regions');
|
|
|
|
const Categories = require('../data/categories');
|
2018-04-06 16:44:08 +03:00
|
|
|
const Account = require('../data/account');
|
2018-03-29 16:43:30 +03:00
|
|
|
|
|
|
|
const {
|
|
|
|
PORT = 4001,
|
|
|
|
BASE_URL = `http://0.0.0.0:${PORT}`,
|
|
|
|
PREFIX = 'navigation',
|
|
|
|
DC_NAME,
|
|
|
|
SDC_URL,
|
|
|
|
SDC_KEY_PATH,
|
|
|
|
SDC_ACCOUNT,
|
|
|
|
SDC_KEY_ID
|
|
|
|
} = process.env;
|
|
|
|
|
|
|
|
const dcName = DC_NAME || Url.parse(SDC_URL).host.split('.')[0];
|
|
|
|
const keyPath = SDC_KEY_PATH;
|
|
|
|
const keyId = `/${SDC_ACCOUNT}/keys/${SDC_KEY_ID}`;
|
|
|
|
const apiBaseUrl = SDC_URL;
|
|
|
|
const baseUrl = BASE_URL;
|
|
|
|
|
|
|
|
Main(async () => {
|
|
|
|
const server = await Server({
|
|
|
|
PORT,
|
|
|
|
BASE_URL
|
|
|
|
});
|
|
|
|
|
2018-05-07 15:33:08 +03:00
|
|
|
await server.register([
|
|
|
|
{
|
|
|
|
plugin: Nav,
|
|
|
|
options: {
|
|
|
|
keyPath,
|
|
|
|
keyId,
|
|
|
|
apiBaseUrl,
|
|
|
|
dcName,
|
|
|
|
baseUrl,
|
|
|
|
regions: Regions,
|
|
|
|
accountServices: Account,
|
|
|
|
categories: Categories
|
|
|
|
},
|
|
|
|
routes: {
|
|
|
|
prefix: `/${PREFIX}`
|
|
|
|
}
|
2018-03-29 16:43:30 +03:00
|
|
|
},
|
2018-05-07 15:33:08 +03:00
|
|
|
{
|
|
|
|
plugin: Ui
|
2018-03-29 16:43:30 +03:00
|
|
|
}
|
2018-05-07 15:33:08 +03:00
|
|
|
]);
|
2018-03-29 16:43:30 +03:00
|
|
|
|
|
|
|
await server.start();
|
|
|
|
});
|