Serverless handlers
Goal: Structure edge and serverless entrypoints in SJS.
Scaffold templates with superjs init workers-api or lambda-handler.
For a full Node backend, see mvb-fastify.
Example
export async function fetch(request: dynamic): Promise<dynamic> {
const url: dynamic = new URL(request.url as string)
const path: string = url.pathname as string
if (path === "/health") {
return new Response("ok", { status: 200 })
}
return new Response("not found", { status: 404 })
}Key takeaways
- Handlers take
dynamicat the platform boundary. - Use
matchon paths and event shapes. - Not decorators — serverless export handlers only.
Next: Tooling tour