-
Notifications
You must be signed in to change notification settings - Fork 20
/
app.js
executable file
·84 lines (69 loc) · 1.46 KB
/
app.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
'use strict';
// This file create a small node server so
// you view the files over http://localhost:3009/
// enter in commandline - $ node app
// Glenn Jones
var Hapi = require('hapi'),
Blipp = require('blipp'),
Pack = require('./package');
var routes = [{
method: 'GET',
path: '/{path*}',
handler: {
directory: {
path: '/tests',
listing: true,
index: false
}
}
},{
method: 'GET',
path: '/css/{path*}',
handler: {
directory: {
path: './css',
listing: true,
index: true
}
}
},{
method: 'GET',
path: '/javascript/{path*}',
handler: {
directory: {
path: './javascript',
listing: true,
index: true
}
}
}];
// Create a server with a host and port
var server = new Hapi.Server();
server.connection({
host: (process.env.PORT)? '0.0.0.0' : 'localhost',
port: parseInt(process.env.PORT, 10) || 3008
});
// hapi server settings
server.route(routes);
var goodOptions = {
opsInterval: 1000,
reporters: [{
reporter: require('good-console'),
events: { log: '*', response: '*' }
}]
};
// Register plug-in and start
server.register([{
register: require('good'),
options: goodOptions
},{
register: require('blipp'),
}], function (err) {
if (err) {
console.error(err);
}else {
server.start(function () {
console.info('Server started at ' + server.info.uri);
});
}
});