Appearance
How to generate a resource module with NestKit?
Creating a resource module from scratch can involve a lot of routine tasks. To simplify this process and leverage the common Resource Module Architecture, you can use the nestkit-cli
to generate a resource module for your project.
Follow this guide to install and set up the nestkit-cli
.
For example, if you want to generate a Resource Module for a Books API, navigate to your project folder and execute the following command:
bash
cd ./my-awesome-nest-project
nestkit generate resource
Or use the shorter version:
bash
cd ./my-awesome-nest-project
nestkit g res
After running the command, the CLI will prompt you to enter the name of the resource (e.g., "book"):
bash
? What is the singular name of the module (e.g. "book", "season-group")?
> books
After you enter the name of the resource, CLI will prompt you to enter the plural name of the resource (e.g., "books"):
bash
? What is the plural entity name of the module (e.g. "books", "season-groups")?
> books
At the end, CLI will prompt you to enter the id prefix of the entity (e.g., "b"):
bash
What is the id prefix of the entity (e.g. "b", "sg")?
> b
Then, the nestkit-cli
will generate the necessary files and folders for your new Books Module based on the common Resource Module Architecture.
This will save you time and effort, as well as ensure consistency in the structure of your NestJS application. Now you can focus on implementing the specific business logic for your API.