@beholdio/ts-lambda-api - v2.4.8
    Preparing search index...

    Class Server

    Server that discovers routes using decorators on controller classes and methods. Processing of requests is preformed by the lambda-api package.

    Index

    Constructors

    • Create a new server.

      Parameters

      • appContainer: Container

        Application container to use to build containers.

      • appConfig: AppConfig

        Application config to pass to lambda-api.

      Returns Server

    Accessors

    Methods

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

      Parameters

      • handler: (this: void, api: API) => void

        Function that takes an API instance as a parameter.

      Returns void

    • Scans the specified path for javascript files and loads these into the current runtime. Importing the files will invoke the decorators declared within them. Note: this scans only the top level files.

      API decorators register controllers, endpoints, configuration and middleware. A series of endpoints are built using the decorator components and registered with the lambda-api package routing engine.

      Controllers and error interceptors registered by decorators are built using an IOC container, which allows dependency injection.

      OpenAPI endpoints will be registered here, if they are enabled in the app config by setting the openApi.enabled flag to true.

      This method must be called before invoking the processEvent method.

      Parameters

      • OptionalcontrollersPath: string[]

        (Optional) Paths to the directories that contain controller js files. Dynamic loading of injectable controllers is disabled if undefined or the app Container instance has its autoBindInjectable flag set to false.

      Returns Promise<void>

    • Takes an API request passed in by AWS Lambda and processes it using the lambda-api package.

      Parameters

      • request: ApiRequest

        API Gateway or ALB request.

      • context: any

        Request context.

      Returns Promise<ApiResponse>

      The response.