forked from kmelve/sanity-podcast-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (32 loc) · 909 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
'use strict';
require('dotenv').config();
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
// application specific logging, throwing an error, or other logic here
});
const Hapi = require('hapi');
const Inert = require('inert');
const { files, podcast, indexRoute, podcastShort } = require('./lib/routes/');
const { favicon } = require('./lib/plugins/');
const server = new Hapi.Server({
port: process.env.PORT || 8888
});
const provision = async () => {
// Add the route
await server.register(Inert);
server.route([indexRoute, files, podcast, podcastShort]);
// Start the server
try {
await server.register([
{
plugin: Inert
}
]);
await server
.start()
.then(() => console.log('Server running:', server.info));
} catch (err) {
console.log(err);
}
};
provision();