-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
34 lines (27 loc) · 807 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
'use strict';
require('module-alias/register');
const Glue = require('@hapi/glue');
const Glob = require('glob');
const serverConfig = require('./config/manifest');
// this is the line we mention in manifest.js
// relativeTo parameter should be defined here
const options = {
...serverConfig.options,
relativeTo: __dirname,
};
// Start server
const startServer = async () => {
try {
const server = await Glue.compose(serverConfig.manifest, options);
const services = Glob.sync('server/services/*.js');
services.forEach((service) => {
server.registerService(require(`${process.cwd()}/${service}`));
});
await server.start();
console.log(`Server listening on ${server.info.uri}`);
} catch (err) {
console.error(err);
process.exit(1);
}
};
startServer();