API Contrats #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
For that level of sharing you really want a contract that describes the full endpoint surface, not just the DTOs. That's where tsoa earns its cost: the controller decorators encode the
route, HTTP method, path params, auth requirements, and request/response types in one place, and the spec is generated from that rather than maintained separately.
The alternative in the shared-package world is something like ts-rest, which is worth knowing about. You define a contract object (routes, params, bodies, responses) in a shared package
using plain TypeScript — no decorators, no OpenAPI step. The backend implements the contract, the frontend consumes it with a typed client. It's lighter than tsoa and fits a plain Express
setup more naturally, but it does mean replacing the router layer with ts-rest's router.
So the real fork in the road is:
Both require touching the REST resource layer. The question is whether you want an OpenAPI spec (for docs, Swagger UI, non-TS consumers) or whether TypeScript-to-TypeScript safety is
sufficient.