-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.js
39 lines (33 loc) · 1 KB
/
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
37
38
39
/* ---------------------------------------------------------------------------------
* @ description : This is the server configration file.
---------------------------------------------------------------------------------- */
import './utilities/global';
import Hapi from 'hapi';
import config from 'config';
import plugins from './plugins';
import logger from './utilities/logger';
import { failActionJoi } from './utilities/rest';
const app = config.get('app');
export default async () => {
const server = new Hapi.Server({
host: app.host,
port: app.port,
routes: {
cors: {
origin: ['*'],
additionalHeaders: ['authorization'],
additionalExposedHeaders: ['authorization']
},
validate: {
failAction: failActionJoi
}
}
});
await server.register(plugins);
try {
await server.start();
} catch (err) {
logger.info(`Error while starting server: ${err.message}`);
}
logger.info(`+++ Server running at: ${server.info.uri}`);
};