ts-lambda-api-local - v2.5.2
    Preparing search index...

    Class ApiConsoleApp

    Simple console application that hosts an express HTTP server.

    A request is mapped from the HTTP request to the ApiServer event format, a ApiServer instance then processes the request. The ApiServer response is mapped to a standard HTTP response and returned to the express client.

    Hierarchy

    • ApiApp
      • ApiConsoleApp
    Index

    Constructors

    • Builds an new console app.

      If appConfig is not passed or the serverLogger property is missing, timestamps will be enabled for logger output.

      Parameters

      • controllersPath: string[]

        The path to the directory containing the API controllers.

      • OptionalappConfig: AppConfig

        Optional configuration for the application. If not provided, default values will be used.

      • OptionalautoInjectionEnabled: boolean

        Whether automatic dependency injection is enabled. Defaults to true if not provided.

      • OptionalappContainer: Container

        An optional container for managing dependencies. If not provided, a new one will be created. You must ensure autoInjectionEnabled reflects your IOC config if you provide an instance here.

      Returns ApiConsoleApp

    Properties

    apiServer: Server
    appConfig: AppConfig
    appContainer: Container
    autoInjectionEnabled: boolean
    controllersPath?: string[]
    expressApp: Application
    initialised: boolean
    logFactory: LogFactory
    logger: ILogger

    Accessors

    • get middlewareRegistry(): MiddlewareRegistry

      Returns MiddlewareRegistry

    Methods

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

      Parameters

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

        Function that takes an API instance as a parameter.

      Returns void

    • Configure the InversifyJS IOC Container instance.

      Parameters

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

        Function that takes a Container instance as a parameter.

      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

      • request: ApiRequest
      • context: any

        Request context.

      Returns Promise<ApiResponse>

      The response.

    • Starts the express server.

      Parameters

      • args: string[]

        Command line arguments for this server, see --help for more info.

      Returns Promise<void>