-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
41 lines (34 loc) · 803 Bytes
/
server.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
// server.js
'use strict';
const Hapi = require('@hapi/hapi');
const Path = require('path');
const Inert = require('@hapi/inert');
const init = async () => {
const server = Hapi.server({
port: 3000,
host: '0.0.0.0',
routes: {
files: {
relativeTo: Path.join(__dirname, 'public')
}
}
});
await server.register(Inert);
server.route({
method: 'GET',
path: '/{param*}',
handler: {
directory: {
path: '.',
index: ['index.html']
}
}
});
await server.start();
console.log('Server running on %s', server.info.uri);
};
process.on('unhandledRejection', (err) => {
console.log(err);
process.exit(1);
});
init();