| 1 | import * as Effect from "effect/Effect"; |
| 2 | import type { HttpEffect } from "../Http.ts"; |
| 3 | import type { BaseRuntimeContext } from "../RuntimeContext.ts"; |
| 4 | |
| 5 | export interface FunctionContext extends BaseRuntimeContext { |
| 6 | /** |
| 7 | * Register an HTTP handler. The optional `shape` payload is the user's |
| 8 | * full default-export shape — Cloudflare Workers use it to expose |
| 9 | * non-handler methods (e.g. `greet`) as RPC methods on the deployed |
| 10 | * `WorkerEntrypoint`. Other platforms (Lambda, etc.) ignore it. |
| 11 | */ |
| 12 | serve<Req = never>( |
| 13 | handler: HttpEffect<Req>, |
| 14 | options?: { shape?: Record<string, unknown> }, |
| 15 | ): Effect.Effect<void, never, Req>; |
| 16 | listen<A, Req = never>( |
| 17 | handler: FunctionListener<A, Req>, |
| 18 | ): Effect.Effect<void, never, Req>; |
| 19 | listen<A, Req = never, InitReq = never>( |
| 20 | effect: Effect.Effect<FunctionListener<A, Req>, never, InitReq>, |
| 21 | ): Effect.Effect<void, never, Req | InitReq>; |
| 22 | exports: Effect.Effect<Record<string, any>, never, never>; |
| 23 | } |
| 24 | |
| 25 | export type FunctionListener<A = any, Req = never> = ( |
| 26 | event: any, |
| 27 | ) => Effect.Effect<A, never, Req> | void; |