Stone.js API
    Preparing search index...

    Tencent SCF Adapter for Stone.js.

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

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

    The type of the raw event received from Tencent SCF.

    The type of the response to send back to Tencent SCF.

    The Tencent SCF 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 { TencentScfAdapter } from '@stone-js/tencent-scf-adapter';

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

    const handler = await adapter.run();

    export { handler };

    Hierarchy

    Index
    • Create an Adapter.

      Parameters

      • blueprint: IBlueprint

        The blueprint to create the adapter.

      Returns TencentScfAdapter

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

      Parameters

      • context: TencentScfAdapterContext

        The event context.

      • OptionaleventHandler: AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

        The event handler to be run.

      Returns Promise<RawResponse>

      The raw response wrapper.

    • Processes an incoming Tencent SCF event.

      This method transforms the raw Tencent SCF 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

      • name: AdapterHookName

        The hook's name.

      • Optionalcontext: TencentScfAdapterContext

        The event context.

      • Optionalerror: any

        The error to handle.

      Returns Promise<void>

    • Handle the event.

      Parameters

      • context: TencentScfAdapterContext

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

      Returns Promise<void>

      If executed outside an Tencent SCF 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 Tencent SCF-compatible handler function.

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

      Type Parameters

      Returns Promise<ExecutionResultType>

      A promise resolving to the Tencent SCF handler function.

      If used outside the Tencent SCF environment.

    • Send the raw event through the destination.

      Parameters

      • context: TencentScfAdapterContext

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

        The context to validate.

      • eventHandler: AdapterEventHandlerType<IncomingEvent, OutgoingResponse>

        The event handler to validate.

      Returns void

      IntegrationError

    • Creates an instance of the TencentScfAdapter.

      Parameters

      • blueprint: IBlueprint

        The application blueprint.

      Returns TencentScfAdapter

      A new instance of TencentScfAdapter.

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