-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
74 lines (61 loc) · 1.48 KB
/
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
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
const Hapi=require('hapi');
const git = require('git-rev-sync');
// Create a server with a host and port
const server=Hapi.server({
host:'0.0.0.0',
port:8000
});
server.auth.scheme("stupidName", require("./schemes/stupidName"));
server.auth.scheme("session", require("./schemes/session"));
server.auth.strategy("default", "session");
async function registerRoutes() {
await server.register({
plugin: require("./routes/config.js"),
options: {
paths: ["api/v1/topic", "api/v1/session"]
}
});
}
async function registerSentry() {
// This will get the SHA1 of out latest release
// We provide this to sentry se we can track errors by release
await server.register({
plugin: require("./helpers/raven/config.js"),
options: {
dsn: process.env.SENTRY_DSN,
id: process.env.SENTRY_ID,
release: git.long()
}
});
}
async function registerSockets() {
await server.register({
plugin: require("./sockets/config.js"),
options: {
}
});
}
// Add the route
server.route({
method:'GET',
path:'/hello',
handler: function(request,h) {
return 'hello world';
}
});
// Start the server
async function start() {
await(registerRoutes());
await(registerSentry());
await(registerSockets());
try {
await server.start();
}
catch (err) {
console.log(err);
process.exit(1);
}
console.log('Server running at:', server.info.uri);
};
start();
module.exports = server;