Set up a CHO project
Choose the package that owns your entry point. You can add another package later when the application gains a second interface.
| Build | Install | First working example |
|---|---|---|
| HTTP API | @chojs/web | Serve a book as JSON |
| Command-line tool | @chojs/command | Print a shelf label |
| Message consumer | @chojs/message | Receive an inventory message |
Create a directory
mkdir library
cd libraryInstall the package
The commands below set up the HTTP example. For a CLI or consumer, substitute the package from the table in the jsr add or deno add command.
deno init
deno add jsr:@chojs/webnpm init -y
npm pkg set type=module
npx jsr add @chojs/web
npm install --save-dev tsx typescript @types/nodebun init -y
bunx jsr add @chojs/webEach tutorial supplies its own app.ts and entry point. Use those contents for the named files, including any starter file generated by your runtime.
Check the environment
For the HTTP tutorial, use a runtime with the global URLPattern API. Check from the same runtime that will start the server.
deno eval 'console.log(typeof URLPattern)'node -p 'typeof URLPattern'bun -e 'console.log(typeof URLPattern)'A result of function means the built-in router is available. For another runtime, use the Hono adapter. CLI and in-memory message delivery work independently of the HTTP router.
Run your first application
Open the tutorial for the package you installed. Each has a complete entry point, an invocation and an expected result. The HTTP tutorial also explains how to test a request before opening a port. HTTP · Command line · Messages