@coobo/base
Advanced tools
Comparing version 1.3.0 to 1.4.0
@@ -5,2 +5,10 @@ # Changelog | ||
## [1.4.0](https://github.com/Coobo/microservice-base/compare/v1.3.0...v1.4.0) (2019-10-14) | ||
### Features | ||
* container injector automatically inputed to express ([a054f3b](https://github.com/Coobo/microservice-base/commit/a054f3b37ee7e4fa22f9cd3bd7d221d1b72e7bf4)) | ||
* server router registering ([f015086](https://github.com/Coobo/microservice-base/commit/f01508655ed6a62bcc942b7faf5e75e513c5af76)) | ||
## [1.3.0](https://github.com/Coobo/microservice-base/compare/v1.2.0...v1.3.0) (2019-10-14) | ||
@@ -7,0 +15,0 @@ |
@@ -1,6 +0,23 @@ | ||
"use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }Object.defineProperty(exports, "__esModule", {value: true});var _di = require('../di'); var _di2 = _interopRequireDefault(_di); | ||
"use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _di = require('../di'); var _di2 = _interopRequireDefault(_di); | ||
exports. default = (req, res, next) => { | ||
/** | ||
* Middleware responsible for identifying incoming requests. | ||
* | ||
* @middleware | ||
* @function ContainerInjectorMiddleware | ||
* @alias ContainerInjectorMiddleware | ||
* @group Application | ||
* @async | ||
* | ||
* @param {import('express').Request} req | ||
* @param {import('express').Response} res | ||
* @param {import('express').NextFunction} next | ||
* | ||
* @returns {void} | ||
*/ | ||
async function ContainerInjectorMiddleware(req, res, next) { | ||
req.container = _di2.default.createScope(); | ||
return next(); | ||
}; | ||
} | ||
module.exports = ContainerInjectorMiddleware; |
@@ -9,2 +9,3 @@ "use strict";require('express-async-errors'); | ||
const ContainerInjectorMiddleware = require('../middlewares/container-in-request'); | ||
const InternalExceptionHandlerMiddleware = require('../middlewares/exception-handler'); | ||
@@ -35,2 +36,3 @@ const InternalRequestIdentifierMiddleware = require('../middlewares/request-identifier'); | ||
requestIdentifier: InternalRequestIdentifierMiddleware, | ||
containerInjector: ContainerInjectorMiddleware, | ||
}; | ||
@@ -47,2 +49,3 @@ | ||
this.use(this._middlewares.requestIdentifier); | ||
this.use(this._middlewares.containerInjector); | ||
this.use(LoggerMiddleware); | ||
@@ -79,2 +82,29 @@ this._enableStatusRoute(); | ||
/** | ||
* Open Router | ||
* | ||
* @method openRouter | ||
* @public | ||
* | ||
* @returns {import('express').Router} | ||
*/ | ||
openRouter() { | ||
return new express.Router(); | ||
} | ||
/** | ||
* Use Router | ||
* | ||
* @method useRouter | ||
* @public | ||
* | ||
* @param {string} basePath | ||
* @param {import('express').Router} router | ||
* | ||
* @returns {void} | ||
*/ | ||
useRouter(basePath = '/', router) { | ||
this._express.use(basePath, router); | ||
} | ||
_setConfigDefaults() { | ||
@@ -81,0 +111,0 @@ this._config.defaults('server', { |
{ | ||
"name": "@coobo/base", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Microservice Base Application", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
378876
1462