Menu

Every response from my API looks the same, and it's two small files: NestJS interceptors in a real project
📰

Every response from my API looks the same, and it's two small files: NestJS interceptors in a real project

DEV Community: nestjs·Ziad Taha·6 days ago
#tmvwhjrW
#devtonestjs#devto#dev#response#every
Long article (695 words) — no AI summary yet.
Reading 0:00
15s threshold

I'm a junior full-stack developer from Alexandria, Egypt. This is another post about FaceMark, my face-recognition attendance system (a NestJS API plus a Python AI service), and it's about the two smallest files in the repo that touch every request: the interceptors.

The problem they solve

An API with twenty endpoints drifts. One controller returns the entity, another returns { message: "ok" } , a third returns whatever the service felt like. The frontend ends up with a different parsing rule per screen, and nobody knows how slow anything is until a user complains.

NestJS's answer is interceptors: code that wraps every handler, sees the request going in and the response going out, and can transform either.…

Continue reading — create a free account

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