Created
February 4, 2017 20:16
-
-
Save crizstian/e2d004c6bb2b731db65d338573a47791 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const {EventEmitter} = require('events') | |
const server = require('./server/server') | |
const repository = require('./repository/repository') | |
const di = require('./config') | |
const mediator = new EventEmitter() | |
console.log('--- Booking Service ---') | |
console.log('Connecting to movies repository...') | |
process.on('uncaughtException', (err) => { | |
console.error('Unhandled Exception', err) | |
}) | |
process.on('uncaughtRejection', (err, promise) => { | |
console.error('Unhandled Rejection', err) | |
}) | |
mediator.on('di.ready', (container) => { | |
repository.connect(container) | |
.then(repo => { | |
container.registerFunction({repo}) | |
return server.start(container) | |
}) | |
.then(app => { | |
app.on('close', () => { | |
container.resolve('repo').disconnect() | |
}) | |
}) | |
}) | |
di.init(mediator) | |
mediator.emit('init') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment