@ccci/run
v1.2.31
Published
Micro Server Helper Utilities is a command-line tool designed to simplify the development process for projects based on the **Micro Server** framework. This utility streamlines tasks such as creating new projects, adding API endpoints, and generating rout
Downloads
73
Readme
Micro Server Helper Utilities
Micro Server Helper Utilities is a command-line tool designed to simplify the development process for projects based on the Micro Server framework. This utility streamlines tasks such as creating new projects, adding API endpoints, and generating routes, controllers, and models.
Features
- Project Initialization: Quickly scaffold a new Micro Server project.
- API Endpoint Generation: Automatically create routes, controllers, and models for new API endpoints.
- Seamless Integration: Ensure generated components align with the Micro Server structure.
Installation
Install the utility globally using Bun.js or npm:
bun add -g @ccci/run # or npm install -g @ccci/runVerify the installation (WIP):
@ccci/run --version
Usage
1. Initialize a New Project
Create a new Micro Server project:
bunx @ccci/run init <project-name>This will scaffold the directory structure, install dependencies, and set up a basic configuration.
2. Generate an API Endpoint
Add a new API endpoint along with the necessary route, controller, and model:
bunx @ccci/run create api <endpoint-name>Example:
bunx @ccci/run create api usersThis creates:
/routes/users.js/controller/UserController.js/models/User.js
3. Generate a Custom Route
Add a standalone route without creating a model or controller:
bunx @ccci/run create route <route-name>Example:
bunx @ccci/run create route productThis creates:
/routes/product.js
4. Generate a Controller
Create a new controller file:
bunx @ccci/run create controller <controller-name>Example:
bunx @ccci/run create controller orderThis creates:
/controller/OrderController.js
5. Generate a Model
Create a new Sequelize model:
bunx @ccci/run create model <model-name>Example:
bunx @ccci/run create model OrderThis creates:
/models/Order.js
Configuration (WIP)
The tool can be configured using a .microserver-helper.config.js file in the project root. Example configuration:
module.exports = {
templates: {
route: './templates/route.js',
controller: './templates/controller.js',
model: './templates/model.js',
},
};Default Templates
Default templates are used for generating files. Modify these templates to suit your project requirements.
Examples
Initialize a Project
bunx @ccci/run init my-new-projectThis creates a new project in the current working directory with the following structure:
my-new-project/
├── /routes
├── /controller
├── /models
├── app.ts
├── package.jsonAdd a New Endpoint
cd my-new-project
bunx @ccci/run create api taskCreates the necessary files for managing a task API endpoint.
Scripts
bunx @ccci/run init: Initialize a new project.bunx @ccci/run create: Generate components (endpoint, route, controller, model).
License
This tool is licensed under the MIT License.
Contributing
Contributions are welcome! Submit a pull request or open an issue to share your ideas or report bugs.
