Skip to content
cho-jsPublic

About

The only cross-platform, cross-runtime, decorator-based framework for building modular applications in TypeScript.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

13 stars

Watchers

1 watching

Forks

Repository files navigation

Cho Logo

The only cross-platform, cross-runtime, decorator-based framework for building modular applications in TypeScript.

Release CI License: MIT

CHO

CHO is an enterprise ready decorator-based framework for building modular applications. It uses modern JavaScript decorators to provide a clean and efficient way to define the structure of an application.

Portability

CHO applications can run on multiple JavaScript runtimes, including Node.js, Deno, Bun, and Cloudflare Workers. This allows developers to write code once and deploy it anywhere, without worrying about runtime-specific issues.

Node.js Logo Deno Logo Bun Logo Cloudflare Workers Logo

A quick look

An HTTP application:

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);
Deno.serve(app.handler); // Bun: Bun.serve({ fetch: app.handler })

A command-line application, with the same modules, controllers and providers:

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"});
Deno.exit(await app.run(Deno.args)); // greet hello --name you

Getting started

Pick the package for what you are building; it brings everything an application needs.

npm install --global @chojs/cli

Or add it to your project with:

# an HTTP application
deno add jsr:@chojs/web
npx jsr add @chojs/web
bunx jsr add @chojs/web

# a command-line application
deno add jsr:@chojs/command
npx jsr add @chojs/command
bunx jsr add @chojs/command

@chojs/web has a router built in, on the standard URL Pattern API, so an HTTP application needs nothing else. To match requests with another HTTP library, give ChoWeb.create the linker of an adapter:

Router Runs on
Built in Deno, Node.js 24, Bun 1.3.4 and Cloudflare Workers: tested on the four
@chojs/vendor-hono Deno, Node.js, Bun and edge runtimes
@chojs/vendor-fastify Node.js only

Deno and Bun run TypeScript decorators directly. On Node.js, compile the application with TypeScript 5 or run it with a tool such as tsx.

Packages

The name of a package links to its guide, and the specification is its full description.

Package Version For Specification
@chojs/web JSR HTTP applications specs
@chojs/command JSR Command-line applications specs
@chojs/message JSR Applications that handle the messages of a broker, such as Kafka specs
@chojs/vendor-cho JSR Middlewares for the built-in router of @chojs/web, such as CORS
@chojs/vendor-hono JSR Running @chojs/web on Hono
@chojs/vendor-fastify JSR Running @chojs/web on Fastify (Node.js only)
@chojs/vendor-kafka JSR Running @chojs/message on Apache Kafka (tested on Deno and Bun too) specs
@chojs/vendor-nats JSR Running @chojs/message on NATS, with replies specs
@chojs/openapi JSR The OpenAPI document of a @chojs/web application, and its page specs
@chojs/dev JSR Development tools: the endpoints of an application, and its graph specs
@chojs/prompt JSR Questions in a terminal: a text, a yes or no, a choice of a list specs
@chojs/cli JSR cho, the command-line tool of the framework specs
@chojs/core JSR The dependency injection engine underneath specs

Runnable examples are in examples/.

Contributing

Contributions are welcome: see CONTRIBUTING.md and the code of conduct.

License

MIT


This project uses the TC39 stage 3 decorators proposal (JavaScript decorators).

蝶

About

The only cross-platform, cross-runtime, decorator-based framework for building modular applications in TypeScript.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

13 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Contributors

Languages