Server API
Reference
The following is the GenzyApi class with all method signatures.
export class GenzyApi {
constructor();
constructor(options: {app?: Application, genzyInfo?: GenzyInfo, basePath?: string});
public intercept(customInterceptors: CustomInterceptors<InterceptorCallback>): GenzyApi;
public interceptAfter(customInterceptors: CustomInterceptors<InterceptorCallback>): GenzyApi;
public interceptAll(callback: InterceptorCallback): GenzyApi;
public interceptAllAfter(callback: InterceptorCallback): GenzyApi;
public withErrors(errors: ErrorRegistry): GenzyApi;
public from(containers: GenzyContainer[]): Application;
}
new GenzyApi(options)
Creates a new instance of GenzyApi.
options<Object>app?<Application>
genzyInfo?<GenzyInfo>
basePath?<string>
genzyApi.from(containers)
Creates a new Express Application from a set of GenzyContainers.
nimbles<Array>
genzyApi.intercept(interceptors)
Registers a set of custom API interceptors that execute
beforeeach request.interceptors<CustomInterceptors>
genzyApi.interceptAfter(interceptors)
Registers a set of custom API interceptors that execute
aftereach request.interceptors<CustomInterceptors>
genzyApi.interceptAll(callback)
Registers a custom API interceptor that executes
beforeall requests.callback<InterceptorCallback>
genzyApi.interceptAllAfter(callback)
Registers a custom API interceptor that executes
afterall requests.callback<InterceptorCallback>
genzyApi.withErrors(errorRegistry)
Registers a set of custom error status codes that set the response status based on the error that is thrown.
errorRegistry<ErrorRegistry>
Types
GenzyInfo
type GenzyInfo = {
version?: string;
name?: string;
description?: string;
basePath?: string;
}
InterceptorCallback
type InterceptorCallback = (req: Request, res: Response, next: NextFunction) => any;
CustomInterceptors
type CustomInterceptors<TInterceptorCallback> = {
[classKey: string]: {
[methodKey: string]: TInterceptorCallback
}
};
ErrorRegistry
type ErrorRegistry = { [key: string]: number };