-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathserver.js
More file actions
58 lines (47 loc) · 974 Bytes
/
server.js
File metadata and controls
58 lines (47 loc) · 974 Bytes
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
const Hapi = require('hapi');
const secret = require('./secret');
const Routes = require('./routes');
const Jwt = require('hapi-auth-jwt2');
const validate = require('./validate');
const Inert = require('inert');
const Vision = require('vision');
const HapiSwagger = require('hapi-swagger');
const server = new Hapi.Server();
server.connection({
port: 3002,
host: 'localhost',
});
const options = {
info: {
title: 'Wallet Documentation',
version: '1.0',
},
};
server.register([
Jwt,
Inert,
Vision,
{
register: HapiSwagger,
options,
}], (err) => {
if (err) {
throw err;
}
});
server.auth.strategy('jwt', 'jwt', {
key: secret,
validateFunc: validate,
verifyOptions: {
algorithms: ['HS256'],
},
});
server.auth.default('jwt');
server.route(Routes);
if (!module.parent) {
server.start((err) => {
if (err) throw (err);
console.log('Server running at:', server.info.uri);
});
}
module.exports = server;