Adapters
GCP Cloud Functions
Google Cloud Functions invokes an HTTP function with the Functions Framework's Express-flavoured (req, res) signature. @stone-js/gcp-cloud-functions-http-adaptermaps that call to an intention, runs your kernel, and writes the response back, so your routes run on Cloud Functions unchanged.
#Install
npm i @stone-js/gcp-cloud-functions-http-adapter#Enable it
Add the decorator (or the blueprint) to the manifest. Your routes, validation, cookies and file uploads are the runtime-agnostic ones from @stone-js/http-core; nothing in the domain changes.
import { StoneApp } from '@stone-js/core'
import { Routing } from '@stone-js/router'
import { GcpCloudFunctionsHttp } from '@stone-js/gcp-cloud-functions-http-adapter'
@GcpCloudFunctionsHttp() // Cloud Functions HTTP trigger
@Routing()
@StoneApp({ name: 'tasks' })
export class Application {}import { defineStoneApp } from '@stone-js/core'
import { routerBlueprint } from '@stone-js/router'
import { gcpCloudFunctionsHttpAdapterBlueprint } from '@stone-js/gcp-cloud-functions-http-adapter'
export const App = defineStoneApp(
{ name: 'tasks' },
[routerBlueprint, gcpCloudFunctionsHttpAdapterBlueprint]
)#Bodies come pre-parsed
The Functions Framework consumes the request stream before your handler runs and hands it the already-parsed body and the untouched rawBody. The adapter reads both, so JSON, form and text bodies work with zero configuration, and the raw payload stays available on the event metadata for webhook signature checks.
#Deploy
Build the function output and deploy the HTTP trigger. The generated entry registers the handler with the Functions Framework under the target name you deploy against.
npm run build # produces the Cloud Functions entry
gcloud functions deploy tasks \
--gen2 --runtime=nodejs20 \
--trigger-http --entry-point=stone --allow-unauthenticatedThe ephemeral per-invocation container matches the Continuum's per-event model exactly: the context is created for the request and collapses after it.
#Generic (non-HTTP) triggers
For events that are not HTTP, a Pub/Sub message, a Cloud Storage change, an Eventarc or scheduler event, use the generic @stone-js/gcp-cloud-functions-adapter with @GcpCloudFunctions(). Every 2nd-gen trigger arrives as a CloudEvent; the adapter normalizes it into an intention whose metadata carries the event's type, source, subject and data, so one handler can dispatch on the event type.
import { GcpCloudFunctions } from '@stone-js/gcp-cloud-functions-adapter'
@GcpCloudFunctions()
@StoneApp({ name: 'workers' })
export class Application {}Register the returned handler with functions.cloudEvent(...) and deploy against the trigger, e.g. --trigger-topic for Pub/Sub. On a thrown error the adapter rethrows by default so Cloud Functions applies its retry policy; opt out with stone.adapter.rethrowOnError = false.
#Triggers
| Package | Type | Description |
|---|---|---|
| @stone-js/gcp-cloud-functions-http-adapter | @GcpCloudFunctionsHttp | HTTP-triggered functions (Functions Framework req/res). Use with @Routing. |
| @stone-js/gcp-cloud-functions-adapter | @GcpCloudFunctions | Generic CloudEvents triggers (Pub/Sub, Cloud Storage, Eventarc, schedulers). |