-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
61 lines (52 loc) · 1.11 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
55
56
57
58
59
60
61
'use strict';
//const Hapi = require('hapi');
import Hapi from 'hapi';
const mongojs = require('mongojs');
// Create a server with a host and port
const server = new Hapi.Server({
connections: {
routes: {
cors: {
origin: ['http://localhost:3000']
}
}
}
});
server.connection({
port: 8080
});
//Connect to db
const registerOpts = [{
register: require('./index')
}];
// Add logging
registerOpts.push({
register: require("good"),
options: {
reporters: {
console: [{
module: 'good-squeeze',
name: 'Squeeze',
args: [{
response: '*',
log: '*'
}]
}, {
module: 'good-console'
}, 'stdout']
}
}
});
//Load plugins and start server
server.register(
registerOpts,
(err) => {
if (err) {
throw err;
}
// Start the server
server.start((err) => {
console.log('Server running at:', server.info.uri);
});
}
);