GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Guide
  • Web
  • Command
  • Message
  • API
  • Blog
  • Documentation status
  • Packages on JSR
  • Releases
  • Contributing
  • chō
  • MIT License
  • Runtime compatibility
  • About chō

This view

  • Original page
  • New address

GeezerVison is showing chojs.io — chō | Modular applications, on every runtime

Skip to content
New Cloudflare Workers support ↗

One framework.
Every runtime.

Build enterprise applications in TypeScript. Share business logic across HTTP APIs, command-line tools and message workers, with explicit module boundaries and dependency checks at startup.

How chō works →View on GitHub ↗
$deno add jsr:@chojs/web
  • Standard decorators
  • No reflection
  • Type-checked DI
main.tsTypeScript
ts
import { ChoWeb, Controller, Get, Module } from "@chojs/web";
import { serve } from "@chojs/web/serve";

@Controller()
class HelloController {
  @Get("")
  hello() {
    return { message: "Hello, world!" };
  }
}

@Module({ controllers: [HelloController] })
class App {}

const app = await ChoWeb.create(App);
await serve(app.handler, { port: 3000 });
GETlocalhost:3000/200 OK
{ "message": "Hello, world!" }

↳ One file. A real application. Your choice of runtime.

At home on
your runtime.

  • Deno
  • Node.js
  • Bun
  • Cloudflare Workers
01 · One shape

Learn the pattern.
Build your thing.

Modules, providers, controllers. The same three building blocks for an API, a CLI or a message consumer. Just change the decorator on the method.

↗HTTP applications@chojs/web→>_Command-line tools@chojs/command→⇄Message consumers@chojs/message→
How chō is organized →
HTTPCommand lineMessages
ts
import {
  ChoWeb,
  type ChoWebContext,
  Controller,
  Get,
  Injectable,
  Module,
} from "@chojs/web";

@Injectable()
class UserStore {
  find(id: string) {
    return { id, name: "Ada" };
  }
}

@Controller({ route: "users", dependencies: [UserStore] })
class UsersController {
  constructor(readonly store: UserStore) {}

  @Get(":id") // GET /users/42
  get(ctx: ChoWebContext) {
    return this.store.find(ctx.params.id!); // sent as JSON
  }
}

@Module({ providers: [UserStore], controllers: [UsersController] })
class App {}

const app = await ChoWeb.create(App);
ts
import {
  Action,
  ChoCommand,
  type ChoCommandContext,
  Controller,
  Help,
  Module,
} from "@chojs/command";

@Controller()
class Greeter {
  @Help("Say hello")
  @Action("hello", { string: ["name"] })
  hello(ctx: ChoCommandContext) {
    console.log(`Hello, ${ctx.args.name ?? "world"}!`);
  }
}

@Module({ controllers: [Greeter] })
class App {}

const app = ChoCommand.create(App, { name: "greet" });
const code = await app.run(Deno.args); // the exit code
ts
import {
  ChoMessage,
  Args, Value,
  Controller,
  Module,
  Subscribe,
} from "@chojs/message";

@Controller({ topic: "orders" })
class OrdersController {
  @Subscribe("created") // the topic orders.created
  @Args(Value<string>("id"))
  created(id: string) {
    console.log("Received order", id);
  }
}

@Module({ controllers: [OrdersController] })
class App {}

const app = await ChoMessage.create(App);
await app.handle("orders.created", { key: "42", value: '{"id":"42"}' });
await app.close();
02 · Portable

Your application.
Your stack.

chō tests HTTP applications on four runtimes: Deno, Node.js, Bun and Cloudflare Workers. A dedicated CI job runs the Workers tests in workerd, including requests that use bindings and background tasks.

  • A router is built in, on the standard URLPattern.
  • Use Hono on all four runtimes or Fastify on Node.js.
  • Call serve(app.handler) in a server process or export fetch: app.handler on Workers.
Runtimes and adapters →
YoursModules, controllers, providers(req: Request) => Response
The framework@chojs/web
An adapter, swapped with one option
Built-in routerHonoFastify
A runtime
DenoNode.jsBunWorkers
03 · Standard decorators

Less magic.
More confidence.

chō runs with TC39 decorators, and with the legacy ones of TypeScript and Bun. Dependencies are declared, not guessed from emitted types, and the compiler checks them against the constructor.

  • No reflect-metadata, no emitDecoratorMetadata.
  • The same application with both forms of decorators.
  • A wrong dependency is a compile error, not a surprise at startup.
Decorators →
ts
const PORT = token<number>("PORT");

@Injectable([Logger, PORT]) // in constructor order
class Server {
  constructor(logger: Logger, port: number) {}
}

@Injectable([PORT, Logger]) 
class Broken {
  constructor(logger: Logger, port: number) {}
}

Compile error: the constructor of Broken wants (Logger, number).

04 · Dependency injection

Catch wiring errors.
Before the first request.

The whole module graph is validated and linked once, when the application is created. A missing provider, a circular import or a duplicate route never waits for the first request.

  • A provider can await a connection before its value is ready.
  • Everything that depends on it waits, with no onInit hook to write.
  • close() releases the instances in reverse order.
Dependency injection →
$ deno run --allow-net main.ts
Error: Cannot resolve Database (argument #0) of UserStore
in module UsersModule. Provide it there or import a module
that exports it.
# fixed, and run again
$ deno run --allow-net main.ts
Error: Duplicate route "GET /users/:id": declared by
UsersController.get and AdminController.find
# fixed
$ deno run --allow-net main.ts
listening on http://localhost:3000
createConfig→Database→UserStore→UsersController
closeUsersController→UserStore→Database→Config

Testing and running
production services.

Test handlers in memory, validate incoming data and resume event processing after downtime with a durable consumer.

@Middlewares · @Catch

Middlewares and error handlers, at every level

On a module, a controller or one method. As a function, or as a class the injector creates, with dependencies of its own.

app.handler(new Request(…))

Tests with no server, and no broker

A request is a function call, and so is a message. Replace any provider with a fake, anywhere in the graph, with overrides.

@Args · validate()

Typed arguments, validated

Declare what a handler reads from the request. Validate and transform inputs with Standard Schema libraries such as Zod, Valibot or ArkType.

@Sse

Server-sent events

A handler is an async generator. Each yield is an event, and a client that leaves ends the loop.

@Main · @Action

Command lines that explain themselves

--help is generated from the flags each command declares. run() returns the exit code.

NATS JetStream

Resume event processing after downtime

A durable consumer picks up stored events, retries failed deliveries and can send exhausted messages to a dead-letter stream.

ChoMessage.from(web.injector)

HTTP and messages, one set of instances

One database pool, one cache, for the requests and for the messages of the same process.

Apache Kafka

Consume Kafka events on three runtimes

Run the same consumer on Node.js, Deno or Bun. Broker tests cover offset commits, retries and partition ordering.

Less setup. More building.

Your next application
starts with one package.

Start with a single file. Grow into modules. Take it to the runtime that works for you.

DenoNode.jsBun
sh
deno add jsr:@chojs/web
sh
npx jsr add @chojs/web
sh
bunx jsr add @chojs/web
Get started →WebCommandMessage
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.