@stone-js/tencent-scf-adapter
v0.8.8
Published
General-purpose Tencent Cloud SCF adapter for Stone.js, run any app on event-driven Serverless Cloud Function triggers, beyond HTTP. Supports COS, CMQ/TDMQ, Timer and CKafka.
Downloads
1,319
Maintainers
Readme
Stone.js - Tencent SCF Adapter
The Tencent SCF Adapter lets your Stone.js application run on event-driven Tencent Cloud Serverless Cloud Function, beyond HTTP. It normalizes any non-HTTP trigger (COS, CMQ/TDMQ, Timer, CKafka) into a Stone.js IncomingEvent, fully aligned with the Continuum Architecture.
For HTTP-triggered functions, use
@stone-js/tencent-scf-http-adapter.
Introduction
In Stone.js, adapters are the translation layer between a platform and your domain. This adapter targets the non-HTTP SCF triggers: the function is invoked with (event, context), and the adapter turns that into a standardized IncomingEvent, runs it through your kernel, and returns a raw response. The event payload is exposed on the event metadata, so one handler can dispatch on the trigger.
It does not own a server: run() returns the (event, context) handler SCF invokes.
Installation
npm install @stone-js/tencent-scf-adapter
# or
pnpm add @stone-js/tencent-scf-adapter
# or
yarn add @stone-js/tencent-scf-adapterRequires
@stone-js/coreand@stone-js/envas peer dependencies.
Usage
Declarative (decorator):
import { StoneApp } from '@stone-js/core'
import { TencentScf } from '@stone-js/tencent-scf-adapter'
@TencentScf()
@StoneApp({ name: 'workers' })
export class Application {}Imperative (blueprint):
import { defineStoneApp } from '@stone-js/core'
import { tencentScfAdapterBlueprint } from '@stone-js/tencent-scf-adapter'
export const App = defineStoneApp({ name: 'workers' }, [tencentScfAdapterBlueprint])run() returns the (event, context) handler SCF invokes:
// index.js — the SCF function entry
exports.main_handler = await stoneApp.run()Failures and retries
SCF treats an event invocation as failed only when the handler rejects. On failure the adapter rethrows by default so SCF's retry / dead-letter policy applies, set stone.adapter.rethrowOnError = false to opt out and manage failures yourself.
Documentation
See the official documentation for the full guide.
