-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (31 loc) · 916 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
'use strict'
console.log(process.env)
const Hapi = require('@hapi/hapi')
const strategy = require('./strategies/')
const plugs = require('./strategies/plugin')
const apiroutes = require('./routes/api')
const authroutes = require('./routes/auth')
const init = async () => {
const server = Hapi.server({
host: 'localhost',
port: process.env.PORT || 8888,
routes: {
cors: true,
},
})
await server.register(plugs)
server.auth.strategy('google', 'bell', strategy.GoogleStrategy)
server.auth.strategy('twitter', 'bell', strategy.TwitterStrategy)
server.auth.strategy('session', 'cookie', strategy.CookieStrategy)
server.auth.default('session')
server.route(apiroutes)
server.route(authroutes)
await server.start()
console.log(`Server running`)
module.exports.server = server
}
process.on('unhandledRejection', (err) => {
console.log(err)
process.exit(1)
})
init()