Stone.js API
    Preparing search index...

    AWS API Gateway WebSocket adapter for Stone.js.

    API Gateway invokes a fresh Lambda per socket event, so this adapter maps requestContext.eventType (CONNECT / DISCONNECT / MESSAGE) into a keyed IncomingEvent and runs it through the kernel, where the light key-router from @stone-js/router routes it to the matching @On* gateway method, the same pattern as every adapter. It maintains the shared connection store (DynamoDB in production); replies to clients go through the API Gateway Management API (see ApiGatewayWsBroadcaster), the management endpoint taken from each event.

    Hierarchy

    Index
    • Create an Adapter.

      Parameters

      • blueprint: IBlueprint

        The blueprint to create the adapter.

      Returns ApiGatewayWsAdapter

    blueprint: IBlueprint
    hooks: AdapterHookType<ApiGatewayWsAdapterContext, RawWsResponse>
    middleware: AdapterMixedPipeType<ApiGatewayWsAdapterContext, RawWsResponse>[]
    resolvedErrorHandlers: Record<
        string,
        IAdapterErrorHandler<RawEventType, RawResponseType, ExecutionContextType>,
    >
    • Build the raw response.

      Parameters

      • context: ApiGatewayWsAdapterContext

        The event context.

      • OptionaleventHandler: AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

        The event handler to be run.

      Returns Promise<RawWsResponse>

      The raw response wrapper.

    • Normalize a socket event into an IncomingEvent and route it through the kernel.

      Parameters

      • context: LambdaContext

        The Lambda execution context.

      • connection: Connection

        The connection.

      • key: string

        The routing key (a lifecycle key or event:<channel>:<event>).

      • Optionalpayload: unknown

        The payload carried to the handler.

      Returns Promise<RawWsResponse>

      The raw response.

    • Execute the event handler lifecycle hooks.

      Parameters

      • hook: KernelHookName

        The hook to execute.

      • eventHandler: AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

        The event handler to be run.

      Returns Promise<void>

    • Execute adapter lifecycle hooks.

      Parameters

      • name: AdapterHookName

        The hook's name.

      • Optionalcontext: ApiGatewayWsAdapterContext

        The event context.

      • Optionalerror: any

        The error to handle.

      Returns Promise<void>

    • Handle the event.

      Parameters

      • context: ApiGatewayWsAdapterContext

        The event context.

      • eventHandler: AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

        The event handler to be run.

      Returns Promise<
          IAdapterEventBuilder<
              RawResponseOptions,
              IRawResponseWrapper<RawWsResponse>,
          >,
      >

      The raw response wrapper.

    • Validate the runtime context and run the start hooks.

      Returns Promise<void>

      When used outside a Node.js/Lambda context.

    • Get the event handler for the adapter.

      Returns AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

      The event handler for the adapter.

      If the event handler is missing.

    • Send the raw event through the destination.

      Parameters

      • context: ApiGatewayWsAdapterContext

        The event context.

      • eventHandler: AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

        The event handler to be run.

      Returns Promise<RawWsResponse>

      Platform-specific response.

      IntegrationError

    • The shared connection store the broadcaster reads, if realtime is enabled.

      Returns ConnectionStore

      The store, or undefined.

    • Point the broadcaster at this event's management endpoint (when it supports it).

      Parameters

      Returns void

    • Validate the context and event handler.

      Parameters

      • context: ApiGatewayWsAdapterContext

        The context to validate.

      • eventHandler: AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

        The event handler to validate.

      Returns void

      IntegrationError