CLI
Generate a complete module with a single command.
The riser-bob command creates a controller, a router and a module for a new feature, so you can start at the interesting part.
Generate a module
Run it from the root of your project:
Terminal
bun run riser-bob g module usersgenerate works as a long form of g.
Terminal
bun run riser-bob generate module usersThe files are created in src/modules/<name>/:
Output
š§½ Module "users" generated successfully!š src/modules/users āāā users.controller.ts āāā users.route.ts āāā users.module.tsThe generated routes live under /api/<name>: POST and GET on /api/users, and GET, PUT and DELETE on /api/users/:id.
Naming
Names may contain letters, numbers, - and _, and must start with a letter. The folder and file names are written in kebab-case and the classes in PascalCase.
| You type | Files | Classes |
|---|---|---|
users | users.controller.ts | UsersController, UsersRouter, UsersModule |
blog-post | blog-post.controller.ts | BlogPostController, BlogPostRouter, BlogPostModule |
BlogPost | blog-post.controller.ts | BlogPostController, BlogPostRouter, BlogPostModule |
After generating
- Register the module in
src/index.ts:new BlogPostModule().register(bob). - Fill in the
TODObodies of the controller. Until you do, every handler fails with a500. - Implement
verifyToken, or remove the auth middleware from the router if the feature is public. Until then the protected routes answer401.
It never overwrites your work
- If any of the three files already exists, the command stops with an error before writing anything.
- If writing fails halfway, the files created by that run are removed again.
Other commands
| Command | Description |
|---|---|
riser-bob --help or -h | Shows usage. |
riser-bob --version or -v | Shows the CLI banner. The version comes from the installed package. |