-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
46 lines (39 loc) · 1.18 KB
/
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
43
44
45
46
const Hapi = require('hapi');
const Vision = require('vision');
const Inert = require('inert');
require('dotenv').config();
const DEFAULT_HOST = 'localhost';
const DEFAULT_PORT = 3000;
const RADIX = 10;
const server = Hapi.server({
host: process.env.HOST || DEFAULT_HOST,
port: parseInt(process.env.PORT, RADIX) || DEFAULT_PORT,
});
/* jshint ignore:start */
const start = async () => {
try {
await server.register(Vision); // template rendering
await server.register(Inert); // static file and directory handlers
server.views({
engines: {
hbs: require('handlebars')
},
relativeTo: __dirname,
path: './views',
layout: true,
layoutPath: './views/layout'
});
server.route(require('./routes/index'));
server.route(require('./routes/project'));
server.route(require('./routes/static-files'));
server.route(require('./routes/twitter'));
server.route(require('./routes/lastfm'));
server.route(require('./routes/github'));
await server.start();
console.log(`Hapi server running at ${server.info.uri}`);
}catch (err) {
console.log('Hapi error starting server', err);
}
};
start();
/* jshint ignore:end */