Stone.js API
    Preparing search index...

    GCP Cloud Functions Adapter for Stone.js.

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

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

    The type of the raw event received from GCP Cloud Functions.

    The type of the response to send back to GCP Cloud Functions.

    The GCP Cloud 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 { GcpCloudFunctionsAdapter } from '@stone-js/gcp-cloud-functions-adapter';

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

    const handler = await adapter.run();

    export { handler };

    Hierarchy

    Index
    • Create an Adapter.

      Parameters

      • blueprint: IBlueprint

        The blueprint to create the adapter.

      Returns GcpCloudFunctionsAdapter

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

      Parameters

      • context: GcpCloudFunctionsAdapterContext

        The event context.

      • OptionaleventHandler: AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

        The event handler to be run.

      Returns Promise<RawResponse>

      The raw response wrapper.

    • Processes an incoming GCP Cloud Functions event.

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

      Parameters

      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

      Returns Promise<void>

    • Handle the event.

      Parameters

      • context: GcpCloudFunctionsAdapterContext

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

      Returns Promise<void>

      If executed outside an GCP Cloud Functions 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 GCP Cloud Functions-compatible handler function.

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

      Type Parameters

      Returns Promise<ExecutionResultType>

      A promise resolving to the GCP Cloud Functions handler function.

      If used outside the GCP Cloud Functions environment.

    • Send the raw event through the destination.

      Parameters

      • context: GcpCloudFunctionsAdapterContext

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

        The context to validate.

      • eventHandler: AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

        The event handler to validate.

      Returns void

      IntegrationError

    • Creates an instance of the GcpCloudFunctionsAdapter.

      Parameters

      • blueprint: IBlueprint

        The application blueprint.

      Returns GcpCloudFunctionsAdapter

      A new instance of GcpCloudFunctionsAdapter.

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