
I Found a Better Way to Build APIs (And It Actually Makes Sense)
so i was just reading some posts on dev.to and came across this idea called contract-driven development looked interesting… so sharing what i understood ⸻ the idea (simple) instead of writing backend first you define your api structure first like: • endpoints • request • response basically a clear blueprint then you build backend based on that ⸻ what is this “contract” it’s just like a fixed structure of your api people usually use OpenAPI it basically creates a JSON file of your API which can be used for: • docs • frontend usage • testing ⸻ setup (what i found people are using) this is the stack i saw most commonly: install packages npm install express zod @trpc/server @trpc/server/adapters/express trpc-openapi if using typescript: npm install -D typescript ts-node @types/node @types/express ⸻ docs (if you want to explore more) • Express → https://expressjs.com/ • Zod → https://zod.dev/ • tRPC → https://trpc.io/ • tRPC OpenAPI → https://github.com/trpc/trpc-openapi • OpenAPI → https:/
Continue reading on Dev.to
Opens in a new tab

.png&w=1200&q=75)