Stone.jsDocs
Paradigm

Adapters

Tencent Cloud SCF

Tencent Cloud Serverless Cloud Function fronts HTTP with API Gateway's proxy integration: the function is invoked with a proxy event (httpMethod, path, headers, queryString, body) and returns { statusCode, headers, body, isBase64Encoded }. @stone-js/tencent-scf-http-adapter maps that to an intention, runs your kernel, and returns the response, so your routes run on SCF unchanged.

#Install

terminalbash
npm i @stone-js/tencent-scf-http-adapter

#Enable it

Add the decorator (or the blueprint) to the manifest. Your routes, validation, cookies and request/response model are the runtime-agnostic ones from @stone-js/http-core; nothing in the domain changes.

app/Application.tsdeclarativeimperative
import { StoneApp } from '@stone-js/core'
import { Routing } from '@stone-js/router'
import { TencentScfHttp } from '@stone-js/tencent-scf-http-adapter'

@TencentScfHttp()   // Tencent SCF HTTP (API Gateway) trigger
@Routing()
@StoneApp({ name: 'tasks' })
export class Application {}
import { defineStoneApp } from '@stone-js/core'
import { routerBlueprint } from '@stone-js/router'
import { tencentScfHttpAdapterBlueprint } from '@stone-js/tencent-scf-http-adapter'

export const App = defineStoneApp(
  { name: 'tasks' },
  [routerBlueprint, tencentScfHttpAdapterBlueprint]
)

#Register the handler

run() returns the (event, context) handler SCF invokes. Export it as the function entry point.

index.jsts
// The SCF function entry
exports.main_handler = await stoneApp.run()

#Generic (non-HTTP) triggers

For triggers that are not HTTP, a COS object change, a CMQ/TDMQ message, a Timer or CKafka records, use the generic @stone-js/tencent-scf-adapter with @TencentScf(). The function is invoked with (event, context); the adapter normalizes it into an intention whose metadata carries the event payload, so one handler can dispatch on the trigger.

app/Application.tsts
import { TencentScf } from '@stone-js/tencent-scf-adapter'

@TencentScf()
@StoneApp({ name: 'workers' })
export class Application {}

On a thrown error the adapter rethrows by default so SCF applies its retry / dead-letter policy; opt out with stone.adapter.rethrowOnError = false.

#Deploy

Build the function output and deploy with Serverless Framework or the console. The per-invocation model matches the Continuum's per-event context exactly.

terminalbash
npm run build
serverless deploy

#Triggers

PackageTypeDescription
@stone-js/tencent-scf-http-adapter@TencentScfHttpHTTP-triggered functions (API Gateway proxy event). Use with @Routing.
@stone-js/tencent-scf-adapter@TencentScfGeneric event triggers (COS, CMQ/TDMQ, Timer, CKafka).

Stone.js

Your app exists in every runtime. Until you run it.

An open-source project by Stone Foundation
Created by Mr. Stone (Evens Pierre)