-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathserver.js
114 lines (80 loc) · 1.78 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
var Hapi = require('hapi');
var server = new Hapi.Server();
var Good = require('good');
var Path = require('path');
/**
* Lets the server run on this Host and Port
*/
server.connection({host:'127.0.0.1',port:3000});
/**
* Routing Static Pages [JS, Css, Images, etc]
*/
server.register(require('inert'), function(err) {
if (err) {
throw err;
}
server.route({
method : 'GET', path : '/public/{path*}', handler : {
directory : {
path : './public',
listing : false,
index : false
}
}
});
});
/**
* Register all Modules as Plugins Here
*
*/
var plugins = [
{ register : require('vision') }, //register Vision with others Plugins
{ register : require('./modules/employees/index.js') },
{ register : require('./modules/user-management/users/index.js') }
];
/**
* Routing Views
*/
server.register(plugins, function (err) {
if (err) {
throw err;
}
server.views({
engines: { html: require('handlebars') },
layout : true,
path: __dirname + '/views',
layoutPath : Path.join(__dirname, './views/layouts'), //setting Global Layout,
partialsPath : Path.join(__dirname,'./views/layouts/partial') //partial Views
});
/**
* Default route
*/
server.route({ method: 'GET', path: '/', handler: function(request, reply) {
reply.view('home/home', {title : 'Home'});
} });
});
/**
* running Http Node Server with Good Plugins for Logging
*/
server.register({
register : Good,
options : {
reporters : [{
reporter : require('good-console'),
events : {
response : '*',
log:'*'
}
}]
}
}, function(error) {
if(error) {
throw error;
}
/**
* Starting Server
*/
server.start(function(){
console.log("Server running on", server.info.uri);
});
});