Stone.js API
    Preparing search index...

    Azure Functions Adapter for Stone.js.

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

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

    The type of the raw event received from Azure Functions.

    The type of the response to send back to Azure Functions.

    The Azure Functions 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 { AzureFunctionsAdapter } from '@stone-js/azure-functions-adapter';

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

    const handler = await adapter.run();

    export { handler };

    Hierarchy

    Index
    • Create an Adapter.

      Parameters

      • blueprint: IBlueprint

        The blueprint to create the adapter.

      Returns AzureFunctionsAdapter

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

      Parameters

      • context: AzureFunctionsAdapterContext

        The event context.

      • OptionaleventHandler: AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

        The event handler to be run.

      Returns Promise<RawResponse>

      The raw response wrapper.

    • Processes an incoming Azure Functions event.

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

      Parameters

      • rawEvent: unknown

        The raw Azure Functions event to be processed.

      • executionContext: AzureFunctionsContext

        The Azure Functions 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: AzureFunctionsAdapterContext

        The event context.

      • Optionalerror: any

        The error to handle.

      Returns Promise<void>

    • Handle the event.

      Parameters

      • context: AzureFunctionsAdapterContext

        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 Azure Functions environment. If not, it throws an error to prevent misuse.

      Returns Promise<void>

      If executed outside an Azure Functions context (e.g., browser).

    • Get the error handler for the given error.

      Parameters

      • error: Error

        The error to get the handler for.

      Returns IAdapterErrorHandler<unknown, RawResponse, AzureFunctionsContext>

      The error handler.

      IntegrationError

    • 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 Azure Functions-compatible handler function.

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

      Type Parameters

      Returns Promise<ExecutionResultType>

      A promise resolving to the Azure Functions handler function.

      If used outside the Azure Functions environment.

    • Send the raw event through the destination.

      Parameters

      • context: AzureFunctionsAdapterContext

        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: AzureFunctionsAdapterContext

        The context to validate.

      • eventHandler: AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

        The event handler to validate.

      Returns void

      IntegrationError

    • Creates an instance of the AzureFunctionsAdapter.

      Parameters

      • blueprint: IBlueprint

        The application blueprint.

      Returns AzureFunctionsAdapter

      A new instance of AzureFunctionsAdapter.

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