-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
71 lines (58 loc) · 1.57 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
'use strict';
const Hapi = require('hapi');
const Good = require('good');
const server = new Hapi.Server();
const couchbase = require('couchbase');
var config = require('./config.json');
var datas = require('./model.json')
var myCluster = new couchbase.Cluster("couchbase://config.couchbase.host");
var Bucket8 = myCluster.openBucket('default');
server.connection({ port: 3000 });
server.register(require('inert'), (err) => {
if (err) {
throw err;
}
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
reply.file('./routes/hello.html');
}
});
server.route({
method: 'GET',
path: '/favicon.ico',
config: {
cache: {
expiresIn: 1000 * 60 * 60 * 24 * 21
}
},
handler: function(request, reply) {
reply.file('./routes/favicon.ico');
}
});
});
server.register({
register: Good,
options: {
reporters: [{
reporter: require('good-console'),
events: {
response: '*',
log: '*',
ops: '*'
}
}]
}
}, (err) => {
if (err) {
throw err; // something bad happened loading the plugin
}
server.start((err) => {
if (err) {
throw err;
}
server.log('info', 'Server running at: ' + server.info.uri);
server.log('info', 'Couchbase server configured on ' + config.couchbase.host + ' at port ' + config.couchbase.port);
});
});