2017-04-28 00:59:03 +03:00
|
|
|
'use strict';
|
|
|
|
|
2017-06-20 02:52:20 +03:00
|
|
|
const Brule = require('brule');
|
2017-06-22 04:05:45 +03:00
|
|
|
const Good = require('good');
|
2017-04-28 00:59:03 +03:00
|
|
|
const Hapi = require('hapi');
|
2017-06-21 00:11:47 +03:00
|
|
|
const Toppsy = require('toppsy');
|
2017-04-28 00:59:03 +03:00
|
|
|
const Portal = require('./lib');
|
|
|
|
|
|
|
|
const server = new Hapi.Server();
|
2017-07-20 16:44:55 +03:00
|
|
|
|
|
|
|
server.connection({
|
|
|
|
port: 3000,
|
|
|
|
routes: {
|
|
|
|
cors: Boolean(process.env.CORS)
|
|
|
|
}
|
|
|
|
});
|
2017-04-28 00:59:03 +03:00
|
|
|
|
2017-06-22 04:05:45 +03:00
|
|
|
const goodOptions = {
|
|
|
|
ops: {
|
2017-06-22 12:57:03 +03:00
|
|
|
interval: 1000
|
2017-06-22 04:05:45 +03:00
|
|
|
},
|
|
|
|
reporters: {
|
|
|
|
consoleReporter: [{
|
|
|
|
module: 'good-squeeze',
|
|
|
|
name: 'Squeeze',
|
2017-09-13 22:32:32 +03:00
|
|
|
args: [{
|
|
|
|
log: '*',
|
|
|
|
response: '*',
|
|
|
|
error: '*'
|
|
|
|
}]
|
2017-06-22 04:05:45 +03:00
|
|
|
}, {
|
|
|
|
module: 'good-console'
|
|
|
|
}, 'stdout']
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-04-28 00:59:03 +03:00
|
|
|
server.register([
|
2017-06-20 02:52:20 +03:00
|
|
|
Brule,
|
2017-08-10 22:56:29 +03:00
|
|
|
Portal,
|
2017-06-22 04:05:45 +03:00
|
|
|
{
|
|
|
|
register: Good,
|
|
|
|
options: goodOptions
|
|
|
|
},
|
2017-06-21 00:11:47 +03:00
|
|
|
{
|
|
|
|
register: Toppsy,
|
2017-09-13 22:32:32 +03:00
|
|
|
options: {
|
|
|
|
namespace: 'portal',
|
|
|
|
subsystem: 'api'
|
|
|
|
}
|
2017-06-21 00:11:47 +03:00
|
|
|
}
|
2017-09-13 22:32:32 +03:00
|
|
|
], (err) => {
|
2017-08-28 23:31:38 +03:00
|
|
|
handlerError(err);
|
|
|
|
server.start((err) => {
|
2017-04-28 00:59:03 +03:00
|
|
|
handlerError(err);
|
2017-08-28 23:31:38 +03:00
|
|
|
console.log(`server started at http://localhost:${server.info.port}`);
|
|
|
|
});
|
2017-09-13 22:32:32 +03:00
|
|
|
});
|
2017-04-28 00:59:03 +03:00
|
|
|
|
|
|
|
function handlerError (error) {
|
|
|
|
if (error) {
|
|
|
|
console.error(error);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
}
|