-
Notifications
You must be signed in to change notification settings - Fork 24
/
index.js
42 lines (33 loc) · 802 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
var Database = require('./database');
var Hapi = require('hapi');
var database = new Database();
var server = new Hapi.Server({debug: {request: ['info', 'error']}});
// Expose database
if (process.env.NODE_ENV === 'test') {
server.database = database;
}
// Create server
server.connection({
host: 'localhost',
port: 8000
});
// Add routes
var plugins = [
{
register: require('./routes/tasks.js'),
options: {
database: database
}
}
];
server.register(plugins, function (err) {
if (err) { throw err; }
if (!module.parent) {
server.start(function(err) {
if (err) { throw err; }
server.log('info', 'Server running at: ' + server.info.uri);
});
}
});
module.exports = server;