-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
36 lines (32 loc) · 873 Bytes
/
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
import Hapi from '@hapi/hapi';
import { config } from './config.js';
import * as pino from './src/infrastructure/pino.js';
import { routes } from './src/infrastructure/routes.js';
const createBareServer = function () {
const serverConfiguration = {
compression: false,
debug: { request: false, log: false },
routes: {
cors: {
origin: ['*'],
additionalHeaders: ['X-Requested-With'],
},
response: {
emptyStatusCode: 204,
},
},
port: config.port,
router: {
isCaseSensitive: false,
stripTrailingSlash: true,
},
};
return Hapi.server(serverConfiguration);
};
async function createServer(controllers) {
const server = createBareServer();
await server.register([pino]);
routes.map(Route => new Route(controllers).register(server));
return server;
}
export { createServer };