-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
65 lines (54 loc) · 1.25 KB
/
example.js
File metadata and controls
65 lines (54 loc) · 1.25 KB
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
const Hapi = require('hapi');
const server = new Hapi.Server({ port: 3000 });
const plugin = require('./index');
// server.connection({ port: 8080, labels: ['test', '1'] });
// server.connection({ port: 8081, labels: ['test', '2'] });
// server.connection({ port: 8081 });
server.route({
path: '/',
method: 'get',
handler: (req) => {
'use strict';
req.log('error', 'err');
req.log('error', new Error());
req.log('log', 'log 1');
setTimeout(() => req.log('later', 'log 2'), 60);
server.log('log', 'this is a server log');
server.log(['log', 'test']);
req.log(['log', 'test']);
throw new Error('up');
return '';
}
});
server.route({
path: '/ignore/me',
method: 'get',
handler: (req, res) => {
'use strict';
return res('');
}
});
server.route({
path: '/test',
method: 'get',
handler: (req) => {
'use strict';
return '';
}
});
(async () => {
await server.register({
plugin,
options: {
ignore: ['/ignore/me'],
custom: {
'auth.credentials.uid': true,
'query': true,
'headers': (x) => JSON.stringify(x).replace(/"/g, '')
},
customFullLengthKey: false,
userFilter: {}
}
});
await server.start();
})().catch(console.error);