2014-08-27 02:51:57 +04:00
|
|
|
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
|
|
|
|
|
|
|
|
2014-12-11 02:16:36 +03:00
|
|
|
var server = new Hapi.Server();
|
|
|
|
server.connection({host: settings.HOST, port: settings.PORT});
|
|
|
|
routes(server);
|
2014-08-06 07:35:25 +04:00
|
|
|
|
2014-12-11 02:16:36 +03:00
|
|
|
server.start(function () {
|
|
|
|
console.log('Listening on %s', server.info.uri);
|
2014-10-17 12:01:50 +04:00
|
|
|
});
|
2014-12-17 05:20:29 +03:00
|
|
|
|
|
|
|
server.register({
|
2014-12-17 09:28:59 +03:00
|
|
|
register: require('hapi-node-postgres'),
|
2014-12-17 05:20:29 +03:00
|
|
|
options: {
|
|
|
|
connectionString: settings.POSTGRES_URL
|
|
|
|
}
|
|
|
|
}, function (err) {
|
|
|
|
if (err) {
|
2014-12-17 09:28:59 +03:00
|
|
|
console.error('Failed to load "hapi-node-postgres" plugin: %s', err);
|
2014-12-17 05:20:29 +03:00
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
});
|