superapp
BackendServer Adapters

Generic (Workers/Deno/Bun)

Use the generic adapter for Cloudflare Workers, Deno, Bun, or any runtime with the Web Fetch API.

Chat in Claude

The generic adapter works with any runtime that supports the standard Request/Response Web API. Use it for Cloudflare Workers, Deno, Bun, or custom servers.

import { createEngine } from '@superapp/backend'
import { createHandler } from '@superapp/backend/adapters/generic'

const engine = createEngine({
  connections: {
    main: process.env.PG_URL!,
  },
})

const handler = createHandler(engine)

export default {
  fetch: (req: Request) => handler(req),
}

Cloudflare Workers

import { createEngine } from '@superapp/backend'
import { createHandler } from '@superapp/backend/adapters/generic'

const engine = createEngine({
  connections: {
    main: process.env.PG_URL!,
  },
})

const handler = createHandler(engine)

export default {
  async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
    return handler(request)
  },
}

Deno

import { createEngine } from '@superapp/backend'
import { createHandler } from '@superapp/backend/adapters/generic'

const engine = createEngine({
  connections: {
    main: Deno.env.get('PG_URL')!,
  },
})

const handler = createHandler(engine)

Deno.serve({ port: 3001 }, (req) => handler(req))

Bun

import { createEngine } from '@superapp/backend'
import { createHandler } from '@superapp/backend/adapters/generic'

const engine = createEngine({
  connections: {
    main: process.env.PG_URL!,
  },
})

const handler = createHandler(engine)

Bun.serve({
  port: 3001,
  fetch: (req) => handler(req),
})

Handler Signature

The generic handler accepts a standard Request and returns a Promise<Response>:

type GenericHandler = (request: Request) => Promise<Response>

This makes it compatible with any runtime or framework that uses the Web Fetch API standard.

On this page