You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
./bin/generator.js server route --path="/api/v1/users" --controller="User" --method="get"
321
+
```
322
+
323
+
This will add a new route to the appropriate route file in the `src/routes` directory.
324
+
325
+
#### Generate a Database Migration
326
+
327
+
```bash
328
+
./bin/generator.js server migration --name="add_user_fields"
329
+
```
330
+
331
+
Options:
332
+
-`--name`: The migration name (required, e.g., "add_user_fields")
333
+
334
+
Example:
335
+
```bash
336
+
./bin/generator.js server migration --name="add_user_profile_fields"
337
+
```
338
+
339
+
This will create a timestamped SQL migration file in the `supabase/migrations` directory. The migration file includes clearly separated sections for "up" migrations (changes to apply) and "down" migrations (how to revert the changes).
After running the generator, you can customize the generated files to fit your specific requirements.
381
+
382
+
## Template-Based Generation
383
+
384
+
The generator script uses a template-based approach for creating files. Templates are stored in the `templates` directory and are organized by category and type:
385
+
386
+
```
387
+
templates/
388
+
├── client/
389
+
│ └── route/
390
+
│ ├── view.html.template
391
+
│ ├── view.js.template
392
+
│ └── initializer.js.template
393
+
└── server/
394
+
├── controller.js.template
395
+
├── route.js.template
396
+
└── migration.sql.template
397
+
```
398
+
399
+
### Benefits of Template-Based Generation
400
+
401
+
1.**Separation of Concerns**: Templates are separate from the generator code, making maintenance easier
402
+
2.**Consistency**: All generated files follow the same structure and style
403
+
3.**Customization**: Templates can be modified without changing the generator code
404
+
4.**Flexibility**: New templates can be added for additional file types
405
+
406
+
### Customizing Templates
407
+
408
+
If you need to modify the structure or content of generated files, you can edit the templates directly. Templates use placeholders like `{{kebabCase}}`, `{{featureName}}`, and `{{controllerName}}` that are replaced with actual values during generation.
409
+
410
+
For example, to change the structure of generated HTML views, edit `templates/client/route/view.html.template`.
0 commit comments