-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (37 loc) · 962 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
45
46
47
const Hapi = require('hapi')
const Path = require('path')
const Boom = require('boom')
const Glob = require('glob')
const Globals = require('./config/globals')
const Db = require('./data/db')
// var routes = require('./config/routes')
var goodConfig = require('./config/good-config.js')
const server = new Hapi.Server()
server.connection({ port: process.env.PORT || 3001 })
server.register([require('hapi-auth-jwt'), {
register: require('good'),
options: goodConfig
}], (err) => {
if (err) {
throw err
}
server.auth.strategy('jwt', 'jwt', {
key: Globals.auth0Secret,
verifyOptions: {
algorithms: [ 'HS256' ]
}
})
Glob.sync('api/**/routes/*.js', {
root: __dirname
}).forEach(file => {
const route = require(Path.join(__dirname, file))
server.route(route)
})
server.start((err) => {
if (err) {
throw err
}
console.log('Server running at:', server.info.uri)
Db.connect()
})
})