nodefony-add-crud

Generates a complete CRUD resource in Nodefony applications including entity, service, controller, and tests.

Updated Dec 19, 2023
One-click install
npx skills add https://github.com/nodefony/nodefony-core --skill nodefony-add-crud-nodefony
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nodefony-add-crud
Source: https://github.com/nodefony/nodefony-core/tree/main/src/packages/%40nodefony/devkit/skills/nodefony-add-crud
Command: npx skills add https://github.com/nodefony/nodefony-core --skill nodefony-add-crud-nodefony

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing a full data resource by hand in a Nodefony application means producing the table definition, validation schemas, CRUD service, REST and WebSocket controller, and tests separately, with subtle details that are easy to miss such as bounded pagination, sortable-field allowlists, and correct HTTP status codes. This Skill drives the nodefony create entity generator so the entire chain is produced consistently in one command. ## Core Features & Use Cases - Full resource generation: One command creates the table, row interface, input validation schemas, CRUD service, dual-transport (REST and WebSocket) controller, and tests. - Field grammar and relations: Supports typed fields (string, text, int, float, bool, json, date, uuid), optional and unique modifiers, ref:<Entity> relations, and composite indexes via repeatable --index and --unique options. - Existing-table mapping: Maps entities onto pre-existing SQL tables with --table, --column-case snake, and --id-name without renaming TypeScript properties. - Use Case: You need to store articles in a Nodefony app. Run the generator with title:string body:text? published:bool and receive a working paginated REST and WebSocket endpoint with tests, instead of hand-writing five files. ## Quick Start Ask the AI to create a new Nodefony entity with your fields, for example: generate an Article resource with a title, optional body text, and a published flag using the nodefony entity generator.

Frequently Asked Questions about nodefony-add-crud

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a CRUD endpoint in Nodefony?

Run npx nodefony create entity with your fields, for example Article title:string body:text? published:bool. The generator produces the table, validation schemas, CRUD service, REST and WebSocket controller, and tests in one step.

How do I define relations and composite indexes between Nodefony entities?

Use ref:<Entity> in the field list to create a relation, whose join column is indexed automatically. For composite indexes, pass repeatable options like --index "siteId,at" and --unique "siteId,path" to the create entity command.

Can Nodefony entities map to an existing SQL table?

Yes, use --table, --column-case snake, and --id-name options when generating the entity. These settings only affect the SQL mapping; TypeScript property names like id and siteId remain unchanged in the service, controller, and tests.

Why doesn't a new field appear in my existing Nodefony database table?

Nodefony only creates tables at startup with CREATE TABLE IF NOT EXISTS and never emits ALTER statements. Adding a column to an existing entity requires writing a migration with npx nodefony orm:generate and applying it with orm:migrate.

How does pagination work in generated Nodefony list endpoints?

List routes return a page object with items, limit, offset, hasNext, and optional total rather than a raw array. Query parameters limit, offset, order, and withTotal are parsed by parsePageQuery, which enforces a sortable-field allowlist and rejects unsortable fields with a 400.

Is the generated delete endpoint protected by default?

Only if @nodefony/security is among the dependencies, in which case the delete action carries @IsGranted("ROLE_ADMIN"). Without that module the delete action is unprotected, so you should add route protection before deploying.