Stone.js API
    Preparing search index...

    AWS Lambda HTTP Adapter for Stone.js.

    The AwsLambdaHttpAdapter extends the functionality of the Stone.js Adapter to provide seamless integration with AWS Lambda for HTTP-based events. This adapter transforms incoming HTTP events from AWS Lambda into IncomingHttpEvent instances and produces a RawHttpResponse as output.

    This adapter simplifies the process of handling HTTP events within AWS Lambda while adhering to the Stone.js framework's event-driven architecture.

    The type of the raw HTTP event from AWS Lambda.

    The type of the raw HTTP response to send back.

    The AWS Lambda execution context type.

    The type of the processed incoming HTTP event.

    Options used to create an incoming HTTP event.

    The type of the outgoing HTTP response after processing.

    Context type specific to the HTTP adapter.

    import { AwsLambdaHttpAdapter } from '@stone-js/aws-lambda-http-adapter';

    const adapter = AwsLambdaHttpAdapter.create({...});

    const handler = await adapter.run();

    export { handler };

    Hierarchy

    Index
    • Create an Adapter.

      Parameters

      • blueprint: IBlueprint

        The blueprint to create the adapter.

      Returns AwsLambdaHttpAdapter

    blueprint: IBlueprint
    middleware: AdapterMixedPipeType<
        AwsLambdaHttpAdapterContext,
        RawHttpResponseOptions,
    >[]
    resolvedErrorHandlers: Record<
        string,
        IAdapterErrorHandler<RawEventType, RawResponseType, ExecutionContextType>,
    >
    • Build the raw response.

      Parameters

      • context: AwsLambdaHttpAdapterContext

        The event context.

      • OptionaleventHandler: AdapterEventHandlerType<IncomingHttpEvent, OutgoingHttpResponse>

        The event handler to be run.

      Returns Promise<RawHttpResponseOptions>

      The raw response wrapper.

    • Processes an incoming AWS Lambda HTTP event.

      Converts a raw AWS Lambda HTTP event into an IncomingHttpEvent, processes it through the Stone.js pipeline, and generates a RawHttpResponse to send back.

      Parameters

      • rawEvent: AwsLambdaHttpEvent

        The raw HTTP event received from AWS Lambda.

      • executionContext: AwsLambdaContext

        The AWS Lambda execution context associated with the event.

      Returns Promise<RawHttpResponseOptions>

      A promise resolving to the processed RawHttpResponse.

    • Execute the event handler lifecycle hooks.

      Parameters

      • hook: KernelHookName

        The hook to execute.

      • eventHandler: AdapterEventHandlerType<IncomingHttpEvent, OutgoingHttpResponse>

        The event handler to be run.

      Returns Promise<void>

    • Execute adapter lifecycle hooks.

      Parameters

      • name: AdapterHookName

        The hook's name.

      • Optionalcontext: AwsLambdaHttpAdapterContext

        The event context.

      • Optionalerror: any

        The error to handle.

      Returns Promise<void>

    • Handle the event.

      Parameters

      • context: AwsLambdaHttpAdapterContext

        The event context.

      • eventHandler: AdapterEventHandlerType<IncomingHttpEvent, OutgoingHttpResponse>

        The event handler to be run.

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

      The raw response wrapper.

    • Initializes the adapter and validates its execution context.

      Ensures that the adapter is running in an AWS Lambda environment. Throws an error if it detects that the adapter is being used in an unsupported environment (e.g., a browser).

      Returns Promise<void>

      If executed outside an AWS Lambda environment.

    • Get the event handler for the adapter.

      Returns AdapterEventHandlerType<IncomingHttpEvent, OutgoingHttpResponse>

      The event handler for the adapter.

      If the event handler is missing.

    • Send the raw event through the destination.

      Parameters

      • context: AwsLambdaHttpAdapterContext

        The event context.

      • eventHandler: AdapterEventHandlerType<IncomingHttpEvent, OutgoingHttpResponse>

        The event handler to be run.

      Returns Promise<RawHttpResponseOptions>

      Platform-specific response.

      IntegrationError

    • Validate the context and event handler.

      Parameters

      • context: AwsLambdaHttpAdapterContext

        The context to validate.

      • eventHandler: AdapterEventHandlerType<IncomingHttpEvent, OutgoingHttpResponse>

        The event handler to validate.

      Returns void

      IntegrationError

    • Creates an instance of the AwsLambdaHttpAdapter.

      Parameters

      • blueprint: IBlueprint

        The application blueprint.

      Returns AwsLambdaHttpAdapter

      A new instance of AwsLambdaHttpAdapter.

      const adapter = AwsLambdaHttpAdapter.create(blueprint);
      await adapter.run();