-
Notifications
You must be signed in to change notification settings - Fork 10
/
di-setup.js
30 lines (24 loc) · 649 Bytes
/
di-setup.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
const awilix = require('awilix');
const DevController = require('./controller/dev');
const DevService = require('./service/dev');
const DevDao = require('./dao/dev');
const db = require('./db');
const container = awilix.createContainer({
injectionMode: awilix.InjectionMode.PROXY,
});
function setup() {
container.register({
devController: awilix.asClass(DevController),
// services
devService: awilix.asClass(DevService),
// DAOs
devDao: awilix.asClass(DevDao),
// inject knexjs object with database connection pooling
// support
db: awilix.asValue(db),
});
}
module.exports = {
container,
setup,
};