inversify-express-utils
Version:
Some utilities for the development of express applications with Inversify
62 lines • 2.55 kB
TypeScript
import 'reflect-metadata';
import express, { Application, Router } from 'express';
import { interfaces } from 'inversify';
import type { AuthProvider, ConfigFunction, RoutingConfig } from './interfaces';
export declare class InversifyExpressServer {
private readonly _router;
private readonly _container;
private readonly _app;
private _configFn;
private _errorConfigFn;
private readonly _routingConfig;
private readonly _authProvider;
private readonly _forceControllers;
/**
* Wrapper for the express server.
*
* @param container Container loaded with all controllers and their dependencies.
* @param customRouter optional express.Router custom router
* @param routingConfig optional interfaces.RoutingConfig routing config
* @param customApp optional express.Application custom app
* @param authProvider optional interfaces.AuthProvider auth provider
* @param forceControllers optional boolean setting to force controllers (defaults do true)
*/
constructor(container: interfaces.Container, customRouter?: Router | null, routingConfig?: RoutingConfig | null, customApp?: Application | null, authProvider?: (new () => AuthProvider) | null, forceControllers?: boolean);
/**
* Sets the configuration function to be applied to the application.
* Note that the config function is not actually executed until a call to
* InversifyExpresServer.build().
*
* This method is chainable.
*
* @param fn Function in which app-level middleware can be registered.
*/
setConfig(fn: ConfigFunction): this;
/**
* Sets the error handler configuration function to be applied to the application.
* Note that the error config function is not actually executed until a call to
* InversifyExpresServer.build().
*
* This method is chainable.
*
* @param fn Function in which app-level error handlers can be registered.
*/
setErrorConfig(fn: ConfigFunction): this;
/**
* Applies all routes and configuration to the server, returning the express application.
*/
build(): express.Application;
private registerControllers;
private mergePaths;
private resolveMiddlewere;
private copyHeadersTo;
private handleHttpResponseMessage;
private handlerFactory;
private _getHttpContext;
private _createHttpContext;
private _getCurrentUser;
private extractParameters;
private getParam;
private _getPrincipal;
}
//# sourceMappingURL=server.d.ts.map