-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
54 lines (40 loc) · 1.18 KB
/
server.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
'use strict';
const Hapi = require('hapi');
const models = require('./models');
// create the server
const server = new Hapi.Server({
port: ~~process.env.PORT || 8777,
debug: {
request: ['error']
}
});
// async function Init() {
// await server.register(
// register: require('hapi-cors'),
// options: {
// origins: ['*'],
// allowCredentials: 'true',
// exposeHeaders: ["Accept", "Authorization", "Content-Type", "If-None-Match", "Accept-language"],
// maxAge: 600,
// methods: ['POST, GET, PUT, OPTIONS'],
// headers: ['Access-Control-Request-Method', 'Access-Control-Request-Headers', 'Accept-Encoding', 'Accept-Language', 'Accept', 'Content-Type', 'Authorization', 'Access-Control-Allow-Origin']
// }
// });
// }
// Init();
server.ext('onRequest', (request, h) => {
console.log('Request received: ' + request.method + ' - ' + request.path);
return h.continue;
});
//API routes...
server.route(require('./lib/routes'));
models.sequelize.sync().then(function () {
server
.start()
.then(() => {
console.log(`Server running at: ${server.info.uri}`);
}) // if needed
.catch(err => {
console.log(err)
})
});