-
Notifications
You must be signed in to change notification settings - Fork 15
/
app.js
61 lines (50 loc) · 1.37 KB
/
app.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');
const Inert = require('inert');
const Vision = require('vision');
const HapiSwagger = require('hapi-swagger');
const Pack = require('./package.json');
const Fs = require('fs');
const _ = require('lodash');
const server = new Hapi.Server({
host: 'localhost',
port: process.env.PORT
});
(async () => {
const HapiSwaggerConfig = {
plugin: HapiSwagger,
options: {
info: {
title: Pack.name,
description: Pack.description,
version: Pack.version
},
swaggerUI: true,
basePath: '/',
pathPrefixSize: 2,
jsonPath: '/docs/swagger.json',
sortPaths: 'path-method',
lang: 'en',
tags: [
{ name: 'api' }
],
documentationPath: '/',
securityDefinitions: {}
}
};
/* register plugins */
await server.register([
Inert,
Vision,
HapiSwaggerConfig
]);
// require routes
Fs.readdirSync('routes').forEach((file) => {
_.each(require('./routes/' + file), (routes) => {
server.route(routes);
});
});
await server.start();
console.log('Server running at:', server.info.uri);
})();
module.exports = server;