galaxy-api/index.js

40 строки
773 B
JavaScript
Исходник Обычный вид История

var settings = require('./settings');
2014-08-06 07:35:25 +04:00
2014-12-11 02:16:36 +03:00
var Hapi = require('hapi');
var routes = require('./api/routes');
2014-08-06 07:35:25 +04:00
var server = module.exports = new Hapi.Server();
server.connection({
host: settings.HOST,
port: settings.PORT,
routes: {
validate: {
options: {
abortEarly: false
}
}
}
});
2014-12-11 02:16:36 +03:00
routes(server);
2014-08-06 07:35:25 +04:00
// Do not start the server when this script is required by another script.
if (!module.parent) {
server.start(function () {
console.log('Listening on %s', server.info.uri);
});
}
server.register({
register: require('hapi-node-postgres'),
options: {
connectionString: settings.POSTGRES_URL
}
}, function (err) {
if (err) {
console.error('Failed to load "hapi-node-postgres" plugin: %s', err);
throw err;
}
});