import "reflect-metadata"; import { Container } from "inversify"; import { API } from "lambda-api"; import { Server } from "./api/Server"; import { AppConfig } from "./model/AppConfig"; import { LambdaApiRequest } from "./model/ApiRequest"; import { ApiResponse } from "./model/ApiResponse"; import { ILogger } from "./util/logging/ILogger"; import { LogFactory } from "./util/logging/LogFactory"; /** * Application base class which combines the `Server`, `Container` (see `InversifyJS`) * and `AppConfig` classes to create a decorator driven API with typescript * middleware and dependency injection. It uses the `lambda-api` package as the * underlying HTTP API framework. * * AWS Lambda requests are handled by the `run` method, which will return a response * compatible with either API Gateway or an ALB. * * Extending this class will allow creating an app implementation for runtimes, * AWS Lambda, Local Web Server etc. */ export declare abstract class ApiApp { protected readonly controllersPath?: string[]; protected appConfig: AppConfig; protected autoInjectionEnabled: boolean; protected appContainer: Container; protected readonly apiServer: Server; protected readonly logFactory: LogFactory; protected logger: ILogger; protected initialised: boolean; get middlewareRegistry(): import("./ts-lambda-api").MiddlewareRegistry; /** * Create a new app. * * @param controllersPath (Optional) Paths to the directories that contain controller `js` files that * declare controllers. Required if the default `Container` is used, or the * `autoInjectionEnabled` is set to `true`. Ignored if the `autoInjectionEnabled` * is set to `false`. * @param appConfig (Optional) Application config to pass to `lambda-api`, defaults to new `AppConfig`. * @param autoInjectionEnabled (Optional) Is auto injection enabled in the IOC container? Defaults to `true`. * @param appContainer (Optional) `InversifyJS` IOC `Container` instance which can * build controllers and error interceptors, defaults to new `Container` using * `autobind` flag set to `true` if `autoInjectionEnabled` is `true`. If you pass your own * instance `autoInjectionEnabled` must reflect the autobind flag passed to the Container. */ constructor(controllersPath?: string[], appConfig?: AppConfig, autoInjectionEnabled?: boolean, appContainer?: Container); /** * Configure the `InversifyJS` IOC `Container` instance. * * @param configureBlock Function that takes a `Container` instance as a parameter. */ configureApp(configureBlock: (this: void, container: Container) => void): void; /** * Configure the `API` instance from the `lambda-api` package. * * @param configureBlock Function that takes an `API` instance as a parameter. */ configureApi(configureBlock: (this: void, api: API) => void): void; /** * Run using the passed event and context, ultimately should call the * `processEvent` method on the `apiServer` instance. * * @param event API Gateway or ALB request. * @param context Request context. * @returns The response. */ abstract run(event: LambdaApiRequest, context: any): Promise; /** * Initialise all controllers and endpoints declared using decorators. */ initialiseControllers(): Promise; }