@vp_solutions/express-skeleton-guard-module
v1.3.7
Published
Guard module for Express Skeleton
Downloads
2
Readme
Guard module for @vp_solutions/express-skeleton
Module description
Guard module provide Router and Controller for processing all not defined routes in app.
For these routes will be rejected Promise with NotFound
error from @vp_solutions/errors
package.
You can handle this rejection with getExpressErrorHandler
middleware from @vp_solutions/errors
package or in your own way.
Example of usage with Inversify IoC container:
Guard module is inversify container module that contain instances of Guard Controller and Router.
For adding it in your project you have to import getGuardModule()
function which returns container module.
Then just load this module into your app container and add Guard Router in your routes chain.
// app-container.ts
import { Container } from 'inversify';
import { getExpressErrorHandler } from '@vp_solutions/errors';
import { getGuardModule } from '@vp_solutions/express-skeleton-guard-module';
import { ILoggerService, LOGGER_SERVICE } from '@vp_solutions/express-skeleton-logger-module';
const appContainer = new Container();
appContainer.load(getGuardModule());
// app.ts
import * as express from 'express';
import { BaseRouter } from '@vp_solutions/express-skeleton-common-module';
import { GUARD_ROUTER } from '@vp_solutions/express-skeleton-guard-module';
const app = express();
app.use('*', appContainer.get<BaseRouter>(GUARD_ROUTER).router);
app.use(getExpressErrorHandler(appContainer.get<ILoggerService>(LOGGER_SERVICE)));