@bodheesh/create-bodhi-node-app v1.0.0
@bodhi/crud-api-generator
A powerful CLI tool that generates Express.js REST APIs or GraphQL endpoints from a simple JSON schema.
Features
- š Instant API generation from JSON schema
- š¾ Support for MongoDB, PostgreSQL, and Firebase
- š Auto-generated CRUD operations
- š Swagger documentation generation
- ā” GraphQL support
- šÆ Clean and maintainable code generation
Installation
npm install -g @bodhi/crud-api-generatorUsage
- Create a JSON schema file (e.g.,
schema.json):
{
"name": "User",
"fields": {
"name": {
"type": "String",
"required": true
},
"email": {
"type": "String",
"required": true,
"unique": true
},
"age": {
"type": "Number"
}
}
}- Generate the API:
bodhi-crud generate -s schema.json -d mongodb -t restOptions:
-s, --schema: Path to JSON schema file (required)-d, --database: Database type (mongodb, postgres, firebase) (default: mongodb)-t, --type: API type (rest, graphql) (default: rest)-o, --output: Output directory (default: ./generated)
Generated Structure
The tool will generate the following files:
generated/
āāā models/
ā āāā user.model.js
āāā controllers/
ā āāā user.controller.js
āāā routes/
ā āāā user.routes.js
āāā swagger.jsonDatabase Support
MongoDB
- Uses Mongoose for schema definition and validation
- Generates complete CRUD operations
- Includes pagination and filtering
PostgreSQL (Coming Soon)
- Sequelize ORM integration
- Migration generation
- Complex queries support
Firebase (Coming Soon)
- Firestore integration
- Real-time updates
- Security rules generation
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT
š¦ rest-api ⣠š src ā ⣠š config ā ā ⣠š index.js # Central configuration ā ā ā š swagger.js # Swagger/OpenAPI configuration ā ⣠š controllers ā ā ⣠š auth ā ā ā ā š auth.controller.js # Authentication controller ā ā ā š user ā ā ā š user.controller.js # User management controller ā ⣠š middleware ā ā ⣠š error.middleware.js # Global error handler ā ā ā š validation ā ā ⣠š auth.middleware.js # JWT authentication ā ā ⣠š auth.validation.js # Auth input validation ā ā ⣠š role.middleware.js # Role-based access control ā ā ā š user.validation.js # User input validation ā ⣠š models ā ā ā š user.model.js # User model schema ā ⣠š routes ā ā ⣠š auth ā ā ā ā š auth.routes.js # Auth routes ā ā ā š user ā ā ā š user.routes.js # User routes ā ⣠š utils ā ā ⣠š db.util.js # Database utilities ā ā ⣠š error.util.js # Error classes ā ā ⣠š logger.util.js # Logging utility ā ā ā š response.util.js # Response formatter ā ā š index.js # Application entry point ⣠š logs # Log files directory ⣠š .env.example # Environment variables example ⣠š .gitignore # Git ignore file ⣠š package.json # Project dependencies ā š README.md # Project documentation
9 months ago