-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (23 loc) · 877 Bytes
/
index.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
'use strict';
const restify = require('restify');
var createRestifyServer = function(args, config, logger) {
const log = logger.create('restify.server');
log.info('Starting restify server...');
let port = typeof config.restifyServer.port !== 'undefined' ? config.restifyServer.port : 8888;
let server = restify.createServer();
server.use(restify.CORS());
// Add possibility to set custom routes for users before server starts
if(config.restifyServer.beforeStart) {
config.restifyServer.beforeStart(server);
}
server.listen(port, () => {
// Add possibility to do something after server has started
if(config.restifyServer.afterStart) {
config.restifyServer.afterStart(server);
}
log.info(`Restify server started on port ${port}`);
});
};
module.exports = {
'framework:restify-server': ['factory', createRestifyServer]
};