Class ApiAppAbstract

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.

Hierarchy

Constructors

  • Create a new app.

    Parameters

    • Optional controllersPath: string[]

      (Optional) Paths to the directories that contain controller js files that declare controllers. Required if the default Container is used, or the provided Container instance has its autoBindInjectable flag set to true. Ignored if the provided Container instance has its autoBindInjectable flag set to false.

    • appConfig: AppConfig = ...

      (Optional) Application config to pass to lambda-api, defaults to new AppConfig.

    • appContainer: Container = ...

      (Optional) InversifyJS IOC Container instance which can build controllers and error interceptors, defaults to new Container with autoBindInjectable flag set to true.

    Returns ApiApp

Properties

apiServer: Server
appConfig: AppConfig = ...

(Optional) Application config to pass to lambda-api, defaults to new AppConfig.

appContainer: Container = ...

(Optional) InversifyJS IOC Container instance which can build controllers and error interceptors, defaults to new Container with autoBindInjectable flag set to true.

controllersPath?: string[]

(Optional) Paths to the directories that contain controller js files that declare controllers. Required if the default Container is used, or the provided Container instance has its autoBindInjectable flag set to true. Ignored if the provided Container instance has its autoBindInjectable flag set to false.

initialised: boolean
logFactory: LogFactory
logger: ILogger

Accessors

Methods

  • Configure the API instance from the lambda-api package.

    Parameters

    • configureBlock: ((this, api) => void)
        • (this, api): void
        • Parameters

          • this: void
          • api: API

          Returns void

    Returns void

  • Configure the InversifyJS IOC Container instance.

    Parameters

    • configureBlock: ((this, container) => void)

      Function that takes a Container instance as a parameter.

        • (this, container): void
        • Parameters

          • this: void
          • container: Container

          Returns void

    Returns void

  • Initialise all controllers and endpoints declared using decorators.

    Returns Promise<void>

  • Run using the passed event and context, ultimately should call the processEvent method on the apiServer instance.

    Parameters

    Returns Promise<ApiResponse>

    The response.

Generated using TypeDoc