1 | /*!
|
2 | * node-mu
|
3 | * node.js minimalistic microservices framework on top of Express.js
|
4 | *
|
5 | * Copyright(c) 2018 IT Resources s.r.l.
|
6 | * Copyright(c) 2018 Luca Stasio <joshuagame@gmail.com>
|
7 | *
|
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 | * of this software and associated documentation files (the "Software"), to deal
|
10 | * in the Software without restriction, including without limitation the rights
|
11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12 | * copies of the Software, and to permit persons to whom the Software is
|
13 | * furnished to do so, subject to the following conditions:
|
14 | *
|
15 | * The above copyright notice and this permission notice shall be included in all
|
16 | * copies or substantial portions of the Software.
|
17 | *
|
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
24 | * SOFTWARE.
|
25 | *
|
26 | * See node-mu license text even in LICENSE file.
|
27 | *
|
28 | * lib/index.js
|
29 | */
|
30 |
|
31 | ;
|
32 |
|
33 | // yeah, I know... it's a global! ... go on :)!
|
34 | Promise = require('bluebird');
|
35 |
|
36 | const inversify = require('inversify');
|
37 | require('reflect-metadata');
|
38 | const ioc = require('./node-mu/ioc');
|
39 | const Application = require('./node-mu/application');
|
40 |
|
41 | const {LoggerWrapper} = require('./node-mu/logger');
|
42 | const logger = new LoggerWrapper('build');
|
43 |
|
44 |
|
45 | /**
|
46 | * Register the application Service class into the inversify IoC Container and returns the managed instance.
|
47 | *
|
48 | * @param applicationClass - the actual service class
|
49 | * @returns {*}
|
50 | */
|
51 | const build = (applicationClass) => {
|
52 | logger.info('starting service', true);
|
53 |
|
54 | const application = ioc.container.get(applicationClass.prototype.ioc.id);
|
55 | logger.info(`service Application instance [${application.id}] builded`, true);
|
56 | return application;
|
57 | };
|
58 |
|
59 | /* main export */
|
60 | exports = module.exports = (applicationClass) => {
|
61 | return build(applicationClass);
|
62 | };
|
63 |
|
64 |
|
65 | /**
|
66 | * Main lib exports
|
67 | * @module node-mu
|
68 | * @public
|
69 | */
|
70 | exports.ioc = ioc;
|
71 | exports.Application = Application;
|
72 | exports.Providers = require('./node-mu/providers');
|
73 | exports.Controllers = require('./node-mu/components').Controllers;
|
74 | exports.Route = require('./node-mu/components').Route;
|
75 | exports.Component = require('./node-mu/components').Component;
|
76 | exports.Repository = require('./node-mu/components').Repository;
|
77 | exports.Service = require('./node-mu/components').Service;
|
78 | exports.LoggerWrapper = LoggerWrapper;
|
79 | exports.Utils = require('./node-mu/utils'); |
\ | No newline at end of file |