Capabilities (Capabilities)
- EventHandler: Write standardized
defineEventHandler。 - Drizzle ORM: Handle database entity definitions, relational queries, and migrations.
- Better-Auth: Integrate authentication middleware and permission checks.
- Parameter Validation: Write robust Zod Schemas for request body and query parameter validation.
Instructions (Instructions)
- Standardized Responses: Must follow
ApiResponseformat, lists must use pagination. - Error Handling: Use
createErrorto throw HTTP exceptions with semantic meaning. - Permission Control: Must call at the top of the Handler
requireAuthorrequireRole。 - Safe Injection: String concatenation of SQL is strictly prohibited.
Usage Example (Usage Example)
Input: "Implement the API for publishing articles."
Action: In server/api/posts.post.ts write the logic, including Zod validation, permission checks, and database writes.