-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
55 lines (46 loc) · 1.02 KB
/
Copy pathserver.js
File metadata and controls
55 lines (46 loc) · 1.02 KB
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
'use strict';
//External Dependencies
var Hapi = require('hapi');
//Internal Dependencies
var Routes = require('./Routes');
var Plugins = require('./Plugins');
const BootStrap = require('./Utils/BootStrap');
//var config = require('./config/dbConfig');
//Create Server
var server = new Hapi.Server();
server.connection({
port: 3000,
routes: { cors: true }
});
//Register All Plugins
const registerPlugins = async () => {
try {
await server.register(Plugins);
} catch (error) {
console.log(error, 'Failed to register hapi plugins');
throw error
}
}
registerPlugins()
//Default Routes
server.route(
{
method: 'GET',
path: '/',
handler: function (req, res) {
//TODO Change for production server
res.view('index')
}
}
);
// attach routes here
server.route(Routes)
//Adding Views
server.views({
engines: {
html: require('handlebars')
},
relativeTo: __dirname,
path: './Views'
});
module.exports = server