new-handler
GitHub根据 Stella 规范脚手架化 Elysia API 处理器。解析资源名和操作,参考现有结构生成包含验证、鉴权及 ORM 访问的代码文件,注册路由并运行检查。
Trigger Scenarios
Install
npx skills add stella/stella --skill new-handler -g -y
SKILL.md
Frontmatter
{
"name": "new-handler",
"description": "Scaffold a new Elysia API handler following Stella's conventions."
}
New Handler
Scaffold a new Elysia API handler following Stella's conventions.
Arguments
$ARGUMENTS — The resource name and operations, e.g. "matters CRUD" or "invoices list,create".
Instructions
-
Parse the arguments to determine:
- Resource name (singular, e.g.
matter,invoice,document) - Operations needed (create, read, update, delete—use
-by-idfor singular-item actions, e.g.read-by-id,update-by-id,delete-by-id; or "CRUD" for all)
- Resource name (singular, e.g.
-
Read existing handlers to understand patterns:
ls apps/api/src/handlers/Pick one handler directory and read its structure as a reference.
-
Create the handler directory and files at
apps/api/src/handlers/{resource}/:index.ts— Elysia plugin exporting all routes- One file per operation (e.g.,
create.ts,read.ts,read-by-id.ts,update-by-id.ts,delete-by-id.ts)
-
Each handler must include:
- Input validation with Zod/Valibot schema
- Authentication check
- Workspace ownership verification (where applicable)
- Drizzle ORM for database access
- Proper error responses (not generic 500s)
-
Follow these patterns:
- Route prefix:
/{resources}(plural) - GET
/:idfor single resource - GET
/for list (with query params for filtering) - POST
/for create - PATCH
/:idfor update - DELETE
/:idfor delete - Return consistent response shapes
- Route prefix:
-
Register the handler in
apps/api/src/index.ts:Add the import and
.use()call following the existing pattern. -
Add tests for functions that transform the data inside the route handler if they are complex enough. Do not add tests for database queries, Elysia route handlers, or macros.
-
Run checks:
bun run typecheck && bun run lint && bun run test
Version History
- 85792bd Current 2026-07-24 16:12


