# A Prompt That Writes Express Endpoints I Actually Ship

> The constraint list that turns a toy endpoint into a production one.

- **Author:** [Youssef Hassan (@youssef_hassan)](https://www.promptabide.com/youssef_hassan)
- **Published:** 2026-05-20
- **Updated:** 2026-08-22
- **Tags:** `backend`, `express`, `typescript`, `api`
- **Views:** 6228
- **Likes:** 176

## Prompt

```
Generated endpoints are usually 80% there and missing exactly the 20% that matters in production. This constraint block closes the gap:

"Write an Express + TypeScript endpoint.

Endpoint: [method] [path]
Purpose: [one sentence]

Non-negotiables:
- Validate the body with express-validator; return 422 with field-level errors
- Auth via the existing authMiddleware; 401 if absent, 403 if the role is wrong
- Wrap DB work in a transaction and roll back on any throw
- No secrets or IDs in log lines
- Return the shared ResponseHelper envelope, never res.json directly
- Paginate any list response, default 20, max 100
- Handle the unique-constraint violation explicitly, not as a 500"

The last two are the ones I used to fix by hand on every single generated endpoint. Putting them in the prompt cut my review time roughly in half.
```

---

Canonical HTML: https://www.promptabide.com/bides/prompt-express-endpoints-youssef-hassan-1
Agent guide: https://www.promptabide.com/llms.txt · https://www.promptabide.com/agent-instructions.md
Sitemap: https://www.promptabide.com/sitemap.xml
