Code Generator
This npm package is a versatile setup tool tailored for Node.js projects, enabling users to generate customized project structures and functionalities. It supports integration with Google Cloud Platform (GCP), RabbitMQ, Redis, a Prisma query generator, and an HTTP module, streamlining the development process and enhancing project efficiency.
Key Features
- GCP Integration: Add Google Cloud Platform (GCP) functionalities to your project.
- RabbitMQ Integration: Seamlessly integrate RabbitMQ, a message broker for managing message queues.
- Redis Integration: Seamlessly integrate Redis, an in-memory data store used for caching, message brokering, and fast data access.
- HTTP Module for API Management: Generate a module that handles API requests with features like retries, backoff, and more.
- Prisma Model CRUD Operations:
- Automate the generation of CRUD operations with pagination support for a specific Prisma model.
- Optionally generate CRUD operations for all models defined in the Prisma schema.
- Interactive CLI: The CLI offers a simple, user-friendly interface with real-time feedback and validation.
Installation
To install the package, use the following command:
npm install @saboosanket/code-generator
Usage
Once installed, you can run the CLI to set up the desired project structure by executing the following command at the root layer where we have prisma folder in case of query generation else in root level where entry point is present :
npx @saboosanket/code-generator
Folder Structure
project-root/
β
βββ README.md # Project documentation
βββ app.js # Main application entry point
βββ controllers/ # Controllers for handling requests
βββ middlewares/ # Middleware functions
βββ node_modules/ # Node.js dependencies
βββ package.json # Package metadata and dependencies
βββ package-lock.json # Exact versions of package dependencies
βββ prisma/ # Prisma schema and migrations
βββ rabbitMQ/ # RabbitMQ integration and related files
βββ redis/ # Redis integration and related files
βββ routes/ # API route definitions
βββ services/ # Business logic and service layer
βββ validations/ # Validation schemas and logic
CLI Prompts
The CLI will guide you through a series of prompts where you can select the features you want to include in your project:
- Cloud Provider: Choose to add GCP functionality.
- RabbitMQ: Opt-in for RabbitMQ integration.
- Redis: Opt-in for Redis integration.
- HTTP Module: Decide if you want the HTTP module to manage API calls with built-in retry and backoff mechanisms.
- Prisma Model Queries:
- Generate CRUD operations for a specific Prisma model, including pagination.
- Optionally generate CRUD operations for all Prisma models in your schema.
Output
After completing the CLI prompts, the package will generate the necessary files and configurations based on your selections, providing a jumpstart to your project.
Hereβs a "TODO" section you can add to your README file to outline future features for adding support for AWS, Kafka, and Sequelize:
TODO
- Integrate functionalities specific to Amazon Web Services (AWS) to expand cloud provider options.
- Implement integration for Apache Kafka, enabling robust streaming capabilities and message processing.
- Add Support for Sequelize:
- Introduce support for Sequelize ORM to manage database interactions for various SQL databases easily.
License
This project is licensed under the MIT License.
Enjoy using the package and feel free to contribute or open issues if you encounter any problems!