Menu

1 / 2

I built a Node.js package that auto-generates API contracts from real traffic

DEV Community·Chaitanya Patil·6 months ago
#ol4hMCWD
#node#typescript#respekt#field#string
Reading 0:00
15s threshold

Last month, a teammate renamed a field from userName to username in a single API endpoint. No tests broke. No TypeScript errors. The PR got merged on a Friday afternoon.

Monday morning, our React app was rendering blank user profiles for every customer. The frontend was reading userName — a field that no longer existed.

The problem: schema drift

API responses change shape over time. It happens in three ways, and none of them are loud about it:

A teammate refactors. They rename a field, change an integer ID to a UUID string, or make a previously-required field optional. The backend tests pass because they test backend logic, not response shape.

A database migration shifts output. You add a column, drop a column, change a default from 0 to null . The ORM happily returns the new shape. Nobody downstream knows.

A third-party API updates quietly. The weather API you depend on starts returning temperature as a string instead of a number. Their changelog?…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.