forked from nagpalarpit/booking-hapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
44 lines (39 loc) · 911 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
42
43
44
const hapi = require('hapi');
const connection = require('./connection');
const routes = require('./routes');
const inert = require("inert");
const vision = require("vision");
const hapi_swagger = require("hapi-swagger");
let PORT = process.env.PORT || 3000;
const init = async () => {
const server = new hapi.server(
{
port: PORT,
host: "localhost"
}
);
const swaggerOption = {
info: {
title: "Booking System"
}
}
await server.register([
inert,
vision,
{
plugin: hapi_swagger,
options: swaggerOption
}
])
try {
connection();
routes(server);
await server.start();
}
catch (err) {
console.log(err),
process.exit(1);
}
console.log(`server running at ${server.info.uri}/documentation`);
}
init();