Skip to content

Futon

A Futon app runs as a Cloudflare Worker: your code is bundled into one module and handles every request to the environment.

Detection

A project is Futon when @rasenganjs/futon is in its dependencies. A project that depends on both @rasenganjs/futon and hono fails detection; deploy each app as its own project.

Your entry file

The entry must default-export a fetch handler. toWinterCgHandler turns a Futon app into one and passes your environment variables through:

src/index.ts
import { Futon, toWinterCgHandler } from '@rasenganjs/futon';
 
const app = new Futon();
 
app.get('/', async () => new Response('Hello from Hiraiship'));
 
export default { fetch: toWinterCgHandler(app) };

A Node.js server doesn't run on Workers: an entry that starts one (NodeDevAdapter, listen()) fails the build with a message saying so. Keep it in a separate file for local development.

How the entry is found

The same as for Hono: Hiraiship runs your build command, then bundles the first entry that exists among index.js in the output directory, the main of a wrangler config file, then src/index.ts, src/index.js, index.ts and index.js. Everything it imports is bundled into one ES module. See Hono.

Defaults

SettingDefault
Install commandFrom your lockfile, see Frameworks
Build commandnpm run build --if-present: your build script, or nothing
Output directorydist, where the entry is looked for first

Environment variables

Variables are on ctx.runtime.env. Pass a type to Futon to have them typed:

src/index.ts
import { Futon, toWinterCgHandler } from '@rasenganjs/futon';
 
type Bindings = { DATABASE_URL: string };
 
const app = new Futon<Bindings>();
 
app.get('/health', async (ctx) => Response.json({ database: Boolean(ctx.runtime.env.DATABASE_URL) }));
 
export default { fetch: toWinterCgHandler(app) };

What's available

The same runtime as Hono: Node.js built-ins through Cloudflare's compatibility layer, outgoing fetch calls up to your plan's limits, no file system.