- Generate CRUD operation files with a single command.
- Supports common REST API endpoints.
- Customizable file generation based on user-defined models and paths.
- Interactive CLI prompts for ease of use.
To install RubbishRoutes, run the following command in your terminal:
npm install -g rubbishroutes
This will install RubbishRoutes globally on your system, allowing it to be run from any project directory.
RubbishRoutes is designed to be intuitive and easy to use. Below are some common use cases:
To generate all CRUD operations for a model, navigate to your project's root directory and run:
rubbishroutes generate --model <ModelName> --path <TargetDirectory>
Example:
rubbishroutes generate --model User --path ./src/controllers
This command will generate CreateUser
, ReadUser
, UpdateUser
, and DeleteUser
functions in the specified directory.
You can also generate specific CRUD operations by specifying the type:
rubbishroutes generate --type <OperationType> --model <ModelName> --path <TargetDirectory>
Available operation types: create
, read
, update
, delete
, list
, search
.
Example:
rubbishroutes generate --type create --model Product --path ./src/controllers
RubbishRoutes allows you to specify the target directory for the generated files. Use the --path
option to define where your CRUD files should be created.
If you run RubbishRoutes without any arguments, it will enter an interactive mode, prompting you for details:
rubbishroutes
RubbishRoutes supports advanced configurations through a .rubbishroutesrc
file. This allows you to set default behaviors, templates, and other settings.
Example .rubbishroutesrc
:
{
"defaultPath": "./src/controllers",
"useMongoDB": true
}
Certainly! To make the usage of "RubbishRoutes" clearer, especially regarding its flags and how to chain them together, we can expand the README.md
with more detailed explanations and examples. Here’s an improved usage section with comprehensive details about each flag and how they can be combined.
RubbishRoutes simplifies the process of generating CRUD operations for Node.js applications through a set of command-line flags. These flags can be combined to customize the generated code to fit your project's structure and requirements.
-
--model <ModelName>
: Specifies the name of the model for which CRUD operations are to be generated. The model name is used in the generated files. -
--type <OperationType>
: Determines the type of CRUD operation to generate. Possible values includecreate
,read
,update
,delete
,list
, andsearch
. If this flag is omitted, all CRUD operations will be generated by default. -
--path <TargetDirectory>
: Defines the directory where the generated files will be placed. The path should be relative to the project's root directory.
You can combine these flags to tailor the generation process. Here are some examples of how to use them:
To generate all CRUD operations for a specific model, use the --model
flag along with the --path
flag:
rubbishroutes generate --model User --path ./src/controllers
This command generates all CRUD operation files for the User
model in the ./src/controllers
directory.
To generate a specific CRUD operation, add the --type
flag:
rubbishroutes generate --type create --model Product --path ./src/controllers
This command will only generate the create
operation for the Product
model.
You can run multiple commands in sequence to generate different operations for the same or different models:
rubbishroutes generate --type create --model Product --path ./src/controllers
rubbishroutes generate --type read --model Product --path ./src/controllers
This sequence of commands generates separate create
and read
operations for the Product
model.
If you prefer not to use flags, simply run rubbishroutes
without any arguments to enter an interactive mode that guides you through the generation process:
rubbishroutes
In this mode, the tool will prompt you for the necessary information, such as the model name, operation type, and target directory.
By providing clear and detailed explanations along with practical examples, users can easily understand how to utilize the "RubbishRoutes" CLI tool effectively, tailoring it to their specific project needs. If there's more you'd like to add or modify, please let me know!
Contributions to RubbishRoutes are welcome! Please read our contributing guidelines for instructions on how to submit pull requests.
RubbishRoutes is MIT licensed.