1 | 'use strict';
|
2 |
|
3 | const _ = require('lodash');
|
4 |
|
5 | class Controller {
|
6 | constructor(service, options, context) {
|
7 | this.service = service;
|
8 | this.options = _.defaults(options, this.defaultOptions);
|
9 | this.context = context;
|
10 | }
|
11 |
|
12 | get defaultOptions() {
|
13 | return {};
|
14 | }
|
15 |
|
16 | dispose() {
|
17 | return this.service.dispose();
|
18 | }
|
19 |
|
20 | static wrapType(Controller, Service) {
|
21 | return function (options, context) {
|
22 | return new Controller(new Service(options, context), options, context);
|
23 | };
|
24 | }
|
25 | }
|
26 |
|
27 | module.exports = Controller;
|