Documentation
CLI
@kynetra/fx-cli is the official scaffolding tool for Kynetra FX. A single command — kynetra new <name> — generates a fully wired project for your target runtime, including a working route handler, middleware stack, runtime adapter, and all configuration files needed to develop and deploy immediately.
Overview#
Rather than copying boilerplate by hand or reading through configuration docs before writing your first route, @kynetra/fx-cli gets you to a running application in under a minute. The generated project is not a starter template with example pages and placeholder comments — it is a minimal, production-shaped scaffold with the correct dependencies, types, and configuration for the runtime you chose.
- Generates
package.jsonwith the correct runtime adapter dependency. - Writes
src/index.tswith a workingcreateFX()app, three standard middleware items, and a root route. - Emits
wrangler.tomlfor Cloudflare Workers projects. - Writes
tsconfig.jsontuned to the target runtime. - Creates
.gitignorecoveringnode_modules,.wrangler, and build output. - Supports four runtimes:
cloudflare(default),node,bun,deno.
Installation and quick start#
@kynetra/fx-cli is designed to be used with npx — no global installation required. The package is self-contained and always runs the latest version.
Run kynetra new
npx @kynetra/fx-cli new my-apiEnter the project directory
cd my-apiInstall dependencies
npm installStart the development server
wrangler dev. For Node, Bun, and Deno projects, use the runtime's native runner.# Cloudflare (default)npx wrangler dev # Nodenode --experimental-strip-types src/index.ts # Bunbun run src/index.ts # Denodeno run --allow-net src/index.tsTip
--runtime at scaffold time rather than editing the generated files afterwards — the adapter import and configuration differ across runtimes.Command reference#
kynetra new
Creates a new project directory and writes all scaffold files into it. The only required argument is the project name.
npx @kynetra/fx-cli new <name> [--runtime cloudflare|node|bun|deno]Full examples for each supported runtime:
# Create a Cloudflare Workers project (default runtime)npx @kynetra/fx-cli new my-api # Create a Node.js projectnpx @kynetra/fx-cli new my-server --runtime node # Create a Bun projectnpx @kynetra/fx-cli new my-bun-app --runtime bun # Create a Deno projectnpx @kynetra/fx-cli new my-deno-app --runtime denoname— the project name. Used as the directory name, thenamefield inpackage.json, and the Worker name inwrangler.toml. Must be a valid npm package name (lowercase, hyphens allowed).--runtime— target runtime. Determines which adapter package is installed and which entry file template is emitted. Defaults tocloudflare.
What gets scaffolded#
Cloudflare Workers (default)
The Cloudflare scaffold includes wrangler.toml in addition to the standard files, and the entry file exports the app through the cloudflare() adapter. Three middleware items — requestId, logger, and cors — are wired by default so the Worker is observable and CORS-ready from the first request.
import { createFX, cors, logger, requestId } from '@kynetra/fx'import { cloudflare } from '@kynetra/fx-cloudflare' const app = createFX({ runtime: 'cloudflare' }) app.use(requestId())app.use(logger())app.use(cors()) app.get('/', (ctx) => ctx.json({ hello: 'world' })) return cloudflare(app)name = "my-api"main = "src/index.ts"compatibility_date = "2024-01-01"Node.js
The Node scaffold uses the @kynetra/fx-node adapter. The serve()call starts an HTTP server on the port specified by the PORT environment variable, falling back to 3000.
import { createFX, cors, logger, requestId } from '@kynetra/fx'import { serve } from '@kynetra/fx-node' const app = createFX({ runtime: 'node' }) app.use(requestId())app.use(logger())app.use(cors()) app.get('/', (ctx) => ctx.json({ hello: 'world' })) serve(app, { port: parseInt(process.env.PORT ?? '3000') })Bun
The Bun scaffold uses the @kynetra/fx-bun adapter. Bun's native HTTP server is used under the hood — no additional configuration is needed.
import { createFX, cors, logger, requestId } from '@kynetra/fx'import { serve } from '@kynetra/fx-bun' const app = createFX({ runtime: 'bun' }) app.use(requestId())app.use(logger())app.use(cors()) app.get('/', (ctx) => ctx.json({ hello: 'world' })) serve(app, { port: parseInt(process.env.PORT ?? '3000') })Deno
The Deno scaffold uses the @kynetra/fx-deno adapter and is compatible with Deno Deploy. The generated file imports from npm specifiers, which Deno resolves automatically when --allow-net is passed.
import { createFX, cors, logger, requestId } from '@kynetra/fx'import { serve } from '@kynetra/fx-deno' const app = createFX({ runtime: 'deno' }) app.use(requestId())app.use(logger())app.use(cors()) app.get('/', (ctx) => ctx.json({ hello: 'world' })) serve(app, { port: parseInt(Deno.env.get('PORT') ?? '3000') })Common files across all runtimes
Every scaffold — regardless of runtime — includes the following files in addition to the runtime-specific src/index.ts:
package.json— project metadata with@kynetra/fxand the runtime adapter as dependencies, plustypescriptas a dev dependency.tsconfig.json— TypeScript configuration withstrict: true,moduleResolution: "bundler", andtarget: "ES2022"..gitignore— coversnode_modules/,.wrangler/,dist/, and*.env.
Warning
Library API#
All CLI behaviour is exposed as a programmatic library. You can use these functions to integrate scaffolding into your own tooling, monorepo setup scripts, or custom generators.
| Name | Type | Description |
|---|---|---|
| scaffoldProject | function | Creates all project files at dir/name. Accepts { name, dir, runtime? }. Returns a promise that resolves when all files are written. |
| parseArgs | function | Parses a process.argv-style string array. Returns { command, name, runtime } — command is always "new" for the current version. |
| run | function | Top-level entry point. Parses argv, validates arguments, and calls scaffoldProject. Equivalent to running the CLI directly. |
Programmatic usage#
Import from @kynetra/fx-cli to scaffold projects from your own scripts. This is useful in monorepo tooling, test fixture setup, or CI pipelines that need to generate fresh projects.
import { scaffoldProject, run } from '@kynetra/fx-cli' // Option 1: call scaffoldProject directlyawait scaffoldProject({ name: 'my-project', dir: process.cwd(), runtime: 'node',}) // Option 2: run the CLI programmatically (parses args the same way the binary does)await run(['new', 'my-project', '--runtime', 'node'])Using scaffoldProject in a monorepo
In a monorepo workflow, you might scaffold new services into a services/subdirectory automatically. Pass dir as the absolute path to that directory and name as the service name.
import { scaffoldProject } from '@kynetra/fx-cli'import path from 'node:path' const name = process.argv[2]if (!name) { console.error('Usage: tsx scripts/new-service.ts <name>') process.exit(1)} await scaffoldProject({ name, dir: path.join(process.cwd(), 'services'), runtime: 'cloudflare',}) console.log(`Created services/${name}`)console.log('Next: cd services/' + name + ' && npm install && npx wrangler dev')Note