-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
59 lines (40 loc) · 1.04 KB
/
app.js
File metadata and controls
59 lines (40 loc) · 1.04 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
56
57
58
59
'use Static';
const Path = require('path');
const Hapi = require('hapi');
const Inert = require('inert');
const Plugin_Base = require('./hapi_plugin_base_route');
const HTTP_PORT = 4000;
const HTTP_PATH = './public/';
const FAYE_ENABLED = true;
const FAYE_PATH = '/faye';
const server = new Hapi.Server({
connections: {
routes: {
files: {
relativeTo: Path.join(__dirname, HTTP_PATH)
}
}
}
});
server.connection({ port: HTTP_PORT });
if (FAYE_ENABLED){
const faye = require('faye');
const bayeux = new faye.NodeAdapter({mount: FAYE_PATH});
bayeux.attach(server.listener);
}
//REGISTERED PLUGINS
server.register([ Inert
, Plugin_Base
], () => {});
// Server Method Sample
server.method('add',function(a,b,next) {
return (next,null,a+b);
})
// Server App Sample
server.app.app_name = 'hapi_template';
server.start((err) => {
if (err) {
throw err;
}
console.log('Server running at:', server.info.uri);
});