-
Notifications
You must be signed in to change notification settings - Fork 6
CLI
The template comes with a Command-Line Interface that helps you to initialize, develop and maintain your projects.
It essentially saves your time by writing boilerplate code for you
The CLI is listed in the dev-dependencies of the template, so all you need to do is
npm install
npm run cli
If you want to, you can install the cli globally with npm install -g templated-project-cli
to be able to launch it with from anywhere
Each time you want to add a new resource to your API, you need to write some boilerplate code (router, middlewares, controllers, tests, and more...)
The CLI saves your time by writing this code for you
npm run cli
- Choose
generate new API resource
- Enter the name of the resource to be created (singular form)
- The CLI will infer the plural form. In case it is not correct, you can still write it by hand
- Relax and take a coffee
You now have a basic CRUD example
The only thing left is to add some data in the database model and to add custom logic in controllers. Enjoy !
However, all the generated code is instantly functional without needing any modification
- Default model in
schema.prisma
- Relations with other existing models in
schema.prisma
- New directory in
src/routes
- Default example routes with CRUD and protections (auth, validation...)
- Default CRUD controllers
- DTOs, ROs, assemblers
- Integration tests skeleton
- Resource linked in
src/routes/index.ts
- ORM re-generated