Skip to content
PromptPilot AI

Library / Coding & Technology / API

Node.js: add a validated API endpoint

Endpoint with schema validation, errors and tests.

Cursor / coding agentsClaude CodeChatGPTClaudenode
Who it's for
Developers using AI coding tools
Use case
API
Output
Agent task · Free
You'll need to fill in
METHOD /pathExpress/Fastify/NestJS/Honodoes X
Prevents: Endpoint trusts req.body and returns inconsistent error shapes.
Add [METHOD /path] to the [Express/Fastify/NestJS/Hono] API that [does X].
- Validate body/query/params with a schema (zod or the framework's validator).
- Keep the handler thin; put logic in a service function.
- Return consistent JSON errors: { error: { code, message } } with correct status codes.
- Check authentication/authorisation.
- Write tests for success, validation failure, and unauthorised access.
Run the tests and the type checker.

Copies your prompt and opens the official site in a new tab. You may need to paste it yourself (Ctrl/⌘ + V). Nothing is sent to the AI by us.

Replace [bracketed] parts with your own details before sending. Want it tailored? Build a custom website & app development prompt.

Before vs after

A typical one-line request compared with this prompt. We only show sample responses where we've written an illustration.

BeforeWhat people usually type

Prompt

api

1 words · no role, context, format or constraints

AfterThis library prompt

Prompt

Add [METHOD /path] to the [Express/Fastify/NestJS/Hono] API that [does X].
- Validate body/query/params with a schema (zod or the framework's validator).
- Keep the handler thin; put logic in a service function.
- Return consistent JSON errors: { error: { code, message } } with correct status codes.
- Check authentication/authorisation.
- Write tests for success, validation failure, and unauthorised access.
Run the tests and the type checker.

68 words · generated instantly from templates, no AI called

What we added

  • Your details: [brackets] for the facts only you know

Related prompts