Skip to main content

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)

genzyApi.from(containers)

genzyApi.intercept(interceptors)

genzyApi.interceptAfter(interceptors)

genzyApi.interceptAll(callback)

genzyApi.interceptAllAfter(callback)

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 };