@stone-js/alibaba-fc-http-adapter
v0.8.6
Published
Alibaba Cloud Function Compute HTTP adapter for Stone.js. Run your app on FC HTTP triggers (req, resp, context) using the Continuum Architecture.
Downloads
562
Maintainers
Readme
Stone.js - Alibaba FC HTTP Adapter
The Alibaba FC HTTP Adapter lets your Stone.js application run on Alibaba Cloud Function Compute HTTP triggers, unchanged. It bridges FC's (req, resp, context) HTTP handler to the Stone.js event system, fully aligned with the Continuum Architecture.
Introduction
In Stone.js, adapters are the translation layer between a platform and your domain. Alibaba Cloud Function Compute (FC 2.0) invokes an HTTP-triggered function with (req, resp, context): a plain request object (with the body pre-read into a Buffer) and an imperative response written via setStatusCode / setHeader / send. This adapter turns the request into a standardized IncomingHttpEvent, runs it through your kernel, and writes the response, so your routes, validation and cookies run on FC with no changes to the domain.
It does not own a server: run() returns the (req, resp, context) handler FC invokes per request.
FC 3.0 runs a container with an ordinary HTTP server, so it does not need this adapter, use
@stone-js/node-http-adapteras-is.
Installation
npm install @stone-js/alibaba-fc-http-adapter
# or
pnpm add @stone-js/alibaba-fc-http-adapter
# or
yarn add @stone-js/alibaba-fc-http-adapterRequires
@stone-js/core,@stone-js/http-coreand@stone-js/filesystemas peer dependencies.
Usage
Declarative (decorator):
import { StoneApp } from '@stone-js/core'
import { Routing } from '@stone-js/router'
import { AlibabaFcHttp } from '@stone-js/alibaba-fc-http-adapter'
@AlibabaFcHttp()
@Routing()
@StoneApp({ name: 'tasks' })
export class Application {}Imperative (blueprint):
import { defineStoneApp } from '@stone-js/core'
import { routerBlueprint } from '@stone-js/router'
import { alibabaFcHttpAdapterBlueprint } from '@stone-js/alibaba-fc-http-adapter'
export const App = defineStoneApp(
{ name: 'tasks' },
[routerBlueprint, alibabaFcHttpAdapterBlueprint]
)run() returns the (req, resp, context) handler FC invokes:
// index.js — the FC HTTP function entry
exports.handler = await stoneApp.run()Documentation
See the official documentation for the full guide.
