Stone.js API
    Preparing search index...

    AWS Lambda Adapter for Stone.js.

    The AwsLambdaAdapter provides seamless integration between Stone.js applications and the AWS Lambda environment. It processes incoming events from AWS Lambda, transforms them into IncomingEvent instances, and returns a RawResponse.

    This adapter ensures compatibility with AWS Lambda's execution model and abstracts the event handling process for Stone.js developers.

    The type of the raw event received from AWS Lambda.

    The type of the response to send back to AWS Lambda.

    The AWS Lambda execution context type.

    The type of the processed incoming event.

    Options used to create an incoming event.

    The type of the outgoing response after processing.

    Context type specific to the adapter.

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

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

    const handler = await adapter.run();

    export { handler };

    Hierarchy

    Index
    • Create an Adapter.

      Parameters

      • blueprint: IBlueprint

        The blueprint to create the adapter.

      Returns AwsLambdaAdapter

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

      Parameters

      • context: AwsLambdaAdapterContext

        The event context.

      • OptionaleventHandler: AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

        The event handler to be run.

      Returns Promise<RawResponse>

      The raw response wrapper.

    • Processes an incoming AWS Lambda event.

      This method transforms the raw AWS Lambda event into a Stone.js IncomingEvent, processes it through the pipeline, and generates a RawResponse to send back.

      Parameters

      • rawEvent: AwsLambdaEvent

        The raw AWS Lambda event to be processed.

      • executionContext: AwsLambdaContext

        The AWS Lambda execution context for the event.

      Returns Promise<RawResponse>

      A promise resolving to the processed RawResponse.

    • 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: AwsLambdaAdapterContext

        The event context.

      • Optionalerror: any

        The error to handle.

      Returns Promise<void>

    • Handle error.

      Parameters

      Returns Promise<AdapterEventBuilderType<RawResponse>>

      The raw response.

    • Handle the event.

      Parameters

      • context: AwsLambdaAdapterContext

        The event context.

      • eventHandler: AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

        The event handler to be run.

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

      The raw response wrapper.

    • Initializes the adapter and validates its execution context.

      Ensures the adapter is running in an AWS Lambda environment. If not, it throws an error to prevent misuse.

      Returns Promise<void>

      If executed outside an AWS Lambda context (e.g., browser).

    • Get the event handler for the adapter.

      Returns AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

      The event handler for the adapter.

      If the event handler is missing.

    • Executes the adapter and provides an AWS Lambda-compatible handler function.

      The run method initializes the adapter and returns a handler function that AWS Lambda can invoke. This handler processes events, manages context, and returns the appropriate response.

      Type Parameters

      Returns Promise<ExecutionResultType>

      A promise resolving to the AWS Lambda handler function.

      If used outside the AWS Lambda environment.

    • Send the raw event through the destination.

      Parameters

      • context: AwsLambdaAdapterContext

        The event context.

      • eventHandler: AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

        The event handler to be run.

      Returns Promise<RawResponse>

      Platform-specific response.

      IntegrationError

    • Validate the context and event handler.

      Parameters

      • context: AwsLambdaAdapterContext

        The context to validate.

      • eventHandler: AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

        The event handler to validate.

      Returns void

      IntegrationError

    • Creates an instance of the AwsLambdaAdapter.

      Parameters

      • blueprint: IBlueprint

        The application blueprint.

      Returns AwsLambdaAdapter

      A new instance of AwsLambdaAdapter.

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