Code generation
Dreamer has a powerful code generation tool that automates the creation of complete CRUD operations from a single migration file. This streamlines your development process by generating all necessary components with minimal configuration.
Basic Usage
To generate a new CRUD, use the following command:
node ace dreamer [entity]
Replace [entity]
with your desired entity name. For example, to create a CRUD for blog posts:
node ace dreamer posts
Workflow
- The command creates a migration file
- You’ll be prompted to edit the file and define your entity fields
- After saving, Dreamer automatically generates all CRUD components
Generated Components
Dreamer creates a complete set of files for your entity:
app/
├── models/
│ └── post.ts
├── controllers/
│ └── posts_controller.ts
├── validators/
│ └── post.ts
├── routes/
│ └── posts.ts
└── docs/ # If Bruno is enabled
└── posts/
└── index.bru
└── show.bru
└── store.bru
└── update.bru
└── destroy.bru
- Model: Lucid model with all field definitions
- Controller: RESTful actions implementation
- Validators: Input validation rules for store and update actions
- Routes: API endpoint definitions
- API Documentation: Automatically generated if Bruno is enabled in your configuration