-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (32 loc) · 928 Bytes
/
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
'use strict';
require('./model/db');
const Hapi = require('hapi');
var Path = require('path');
var routes = require('./config/routes');
var staticPath = require('./config/static_path');
var goodConfig = require('./config/good-config.js')
const server = new Hapi.Server();
console.log(`Relative: ${Path.join(__dirname, staticPath)}`);
server.connection({ port: process.env.PORT || 3000 });
server.register([require('inert'), require('hapi-auth-jwt'), {
register: require('good'),
options: goodConfig
}], (err) => {
if (err) {
throw err;
}
server.auth.strategy('token', 'jwt', {
key: new Buffer(process.env.AUTH0_CLIENT_SECRET, 'base64'),
verifyOptions: {
algorithms: [ 'HS256' ],
audience: process.env.AUTH0_CLIENT_ID
}
});
server.route(routes);
server.start((err) => {
if (err) {
throw err;
}
console.log('Server running at:', server.info.uri);
});
})