joyent-portal/bundle/src/navigation.js

73 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-04-06 17:53:44 +03:00
require('../.env.js');
2018-03-29 16:43:30 +03:00
const Main = require('apr-main');
const Nav = require('hapi-webconsole-nav');
2018-04-06 17:53:44 +03:00
const Graphi = require('graphi');
2018-03-29 16:43:30 +03:00
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');
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([
2018-04-06 17:53:44 +03:00
{
plugin: Graphi,
options: {
graphqlPath: '/graphql',
graphiqlPath: '/graphiql',
authStrategy: 'sso'
},
routes: {
prefix: `/${PREFIX}`
}
},
2018-05-07 15:33:08 +03:00
{
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();
});