@gabliam/web-core
Version:
Gabliam plugin for add web-core
93 lines (92 loc) • 2.55 kB
TypeScript
import { Container, inversifyInterfaces } from '@gabliam/core';
import { ServerConfig } from './interface';
import { PipeId } from './metadatas';
import { ServerStarter } from './server-starter';
/**
* Config function
*
* For configure application
*/
export type ConfigFunction<T = any> = (app: T, container: Container) => void;
/**
* Configuration
*/
export interface Configuration<T = any> {
/**
* execution order
*/
order: number;
/**
* instance of configFunction
*/
instance: ConfigFunction<T>;
}
export interface WebConfigurationContructor<T = any> {
/**
* All web config
*
* Function call before build controller
*
* For add configuration of you server (express or koa middleware)
*/
webconfig: Configuration<T>[];
/**
* All web config
*
* Function call after build controller
*
* For add configuration of you server (express middleware of error)
*/
webconfigAfterCtrl: Configuration<T>[];
/**
* All interceptors.
* Call on all methods
*/
globalInterceptors: inversifyInterfaces.ServiceIdentifier<any>[];
/**
* All pipes.
* Call on all methods
*/
globalPipes: PipeId[];
/**
* All pipes.
* Call on all methods
*/
serverConfigs: ServerConfig[];
/**
* Inlude Error Interceptor
* By default true
*/
includeErrorInterceptor: boolean;
/**
* Server starter
*
* By default HttpServerStarter
*/
serverStarter: ServerStarter;
}
/**
* Web Config
*
* This class is a storage of all web configuration
*/
export declare class WebConfiguration<T = any> {
private _webconfig;
private _webconfigAfterCtrl;
private _globalInterceptors;
private _globalPipes;
private _serverConfigs;
private _serverStarter;
constructor(config?: Partial<WebConfigurationContructor<T>>);
get webConfigs(): Configuration<T>[];
get WebConfigAfterCtrls(): Configuration<T>[];
get globalInterceptors(): inversifyInterfaces.ServiceIdentifier<any>[];
get globalPipes(): PipeId[];
get serverConfigs(): ServerConfig[];
get serverStarter(): ServerStarter;
addwebConfig(webConfig: Configuration<T>): void;
addWebConfigAfterCtrl(webConfig: Configuration<T>): void;
useGlobalInterceptor(...ids: inversifyInterfaces.ServiceIdentifier<any>[]): void;
useGlobalPipes(...ids: inversifyInterfaces.ServiceIdentifier<any>[]): void;
addServerConfigs(...configs: ServerConfig[]): void;
}