<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/day-2-30-keep-controllers-thin-mm5mtrovs" -->

---
title: Day 2/30 — Keep Controllers Thin | daily.dev
description: A short reminder about the single responsibility principle applied to controllers in backend frameworks like NestJS. Controllers should only handle HTTP...
canonical: https://daily.dev/posts/day-2-30-keep-controllers-thin-mm5mtrovs
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Day 2/30 — Keep Controllers Thin | daily.dev
og:description: A short reminder about the single responsibility principle applied to controllers in backend frameworks like NestJS. Controllers should only handle HTTP...
og:url: https://daily.dev/posts/day-2-30-keep-controllers-thin-mm5mtrovs
og:image: https://api.daily.dev/og/posts/mM5mTroVs.png
og:image:alt: Day 2/30 — Keep Controllers Thin
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Day 2/30 — Keep Controllers Thin

**[Nestjs Developers](https://daily.dev/sources/nestjsdevs)** · [@ezilemdodana](https://daily.dev/ezilemdodana) · 1 min read · 231 upvotes · 45 comments

## Summary

A short reminder about the single responsibility principle applied to controllers in backend frameworks like NestJS. Controllers should only handle HTTP concerns — accepting requests, reading context, delegating work, and returning responses. When a controller starts containing business logic like price calculation, transaction management, or email sending, it has grown beyond its intended role. The post encourages keeping controllers thin by delegating business logic to dedicated service layers.

## Content

A controller should understand HTTP. It should not understand your entire business.

Its job is usually simple:

- Accept the request
- Read the request context
- Delegate the work
- Return the response

If your controller calculates prices, opens transactions, updates repositories and sends emails, it is no longer a controller.

It is a business process wearing an HTTP costume.

What is the worst controller you have inherited?

![nest02.png](https://media.daily.dev/image/upload/s--c1iDF5XL--/f_auto/v1785323255/ugc/content_b7308bdb-d13d-46b2-984d-62793d610239?_a=BAMAMicg0)

#NestJS #CleanArchitecture #APIDesign

## Community discussion

Top comments from developers on daily.dev.

**@vh\_lago** · 5 upvotes

> I really liked the intro to your post, but I still have some questions. Currently, I'm a Python/Django dev learning TS for frontend development whit React. After all, what exactly are controllers, what are they used for, and where should I use them? Your post made it clear that controllers should be small and limited to specific tasks. By the way, I'm really enjoying the '30 days of NestJS' series and I'll be following along. Congrats

**@muchamadfaiz** · 3 upvotes

> yea same thought

**@vladsiu** · 2 upvotes

> It's too clean, sometimes in big projects it's kind of hard to keep like so

**@muhammadahsanmirza** · 2 upvotes

> Agreed - business logic should be in service methods

**@akhlaqurrahmanomi** · 2 upvotes

> But for me, the controller gets messy with OpenApi stuff. Is there an alternative way to overcome that?

---

Tags: [#architecture](https://daily.dev/tags/architecture), [#backend](https://daily.dev/tags/backend), [#nestjs](https://daily.dev/tags/nestjs)

[View this post on daily.dev](https://daily.dev/posts/day-2-30-keep-controllers-thin-mm5mtrovs)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/day-2-30-keep-controllers-thin-mm5mtrovs","headline":"Day 2/30 — Keep Controllers Thin","text":"A short reminder about the single responsibility principle applied to controllers in backend frameworks like NestJS. Controllers should only handle HTTP concerns — accepting requests, reading context, delegating work, and returning responses. When a controller starts containing business logic like price calculation, transaction management, or email sending, it has grown beyond its intended role. The post encourages keeping controllers thin by delegating business logic to dedicated service layers.","url":"https://daily.dev/posts/day-2-30-keep-controllers-thin-mm5mtrovs","datePublished":"2026-07-29T11:07:41.999Z","dateModified":"2026-07-30T00:17:48.426Z","author":{"@type":"Person","name":"Ezile Mdodana","url":"https://daily.dev/ezilemdodana","image":"https://media.daily.dev/image/upload/s--1OI8gwnO--/f_auto/v1771923757/avatars/avatar_7vB9SeLRKhOHGnzEpmFvQ?_a=BAMAMiiu0","description":"Software Project Lead sharing practical insights on NestJS, Angular, AWS and scalable systems.","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":8420}},"interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":231},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":45}],"comment":[{"@type":"Comment","text":"I really liked the intro to your post, but I still have some questions. Currently, I’m a Python/Django dev learning TS for frontend development whit React. After all, what exactly are controllers, what are they used for, and where should I use them? Your post made it clear that controllers should be small and limited to specific tasks. By the way, I’m really enjoying the ‘30 days of NestJS’ series and I’ll be following along. Congrats","datePublished":"2026-07-29T11:49:06.615Z","url":"https://daily.dev/posts/mM5mTroVs#c-64EXhUHUQ","author":{"@type":"Person","name":"Victor Hugo Medeiros do Lago Soares","url":"https://daily.dev/vh_lago","image":"https://lh3.googleusercontent.com/a/ACg8ocKO5kY_2rdXH-EBMIhdYOo5SKqs2IJxFlUsdb24T6ZHN96mmntf=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":5}},{"@type":"Comment","text":"yea same thought","datePublished":"2026-07-29T11:36:44.592Z","url":"https://daily.dev/posts/mM5mTroVs#c-ufBdw9nlJ","author":{"@type":"Person","name":"Muchamad Faiz","url":"https://daily.dev/muchamadfaiz","image":"https://lh3.googleusercontent.com/a/ACg8ocK21bv98rlHfTwxWPkwQnpYkBLhSGWV-aBKNRV9NEIQHHyOHXvX=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":3}},{"@type":"Comment","text":"It’s too clean, sometimes in big projects it’s kind of hard to keep like so","datePublished":"2026-07-30T04:21:58.595Z","url":"https://daily.dev/posts/mM5mTroVs#c-rkI9nlG5h","author":{"@type":"Person","name":"Vladislav Siumbeli","url":"https://daily.dev/vladsiu","image":"https://media.daily.dev/image/upload/s--GalxSgjS--/f_auto/v1757768087/avatars/avatar_ezH33Lu6a37KM1SfsCwIx?_a=BAMClqZW0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"Agreed - business logic should be in service methods","datePublished":"2026-07-30T04:23:12.380Z","url":"https://daily.dev/posts/mM5mTroVs#c-79mEzXDjM","author":{"@type":"Person","name":"Muhammad Ahsan","url":"https://daily.dev/muhammadahsanmirza","image":"https://media.daily.dev/image/upload/s--uMYYiAB_--/f_auto/v1784451760/avatars/avatar_hl2Lw4tWjUHx4KfLmYQXK?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"But for me, the controller gets messy with OpenApi stuff. Is there an alternative way to overcome that?","datePublished":"2026-07-30T09:06:49.380Z","url":"https://daily.dev/posts/mM5mTroVs#c-4OUQoyXmB","author":{"@type":"Person","name":"Akhlaqur Rahman Omi","url":"https://daily.dev/akhlaqurrahmanomi","image":"https://lh3.googleusercontent.com/a/ACg8ocI1dnma6L1Di5ZW8C5WpjM5mpj16Hu409UEFxjQ6I3EyWSqcgYv=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/nestjsdevs","name":"Nestjs Developers"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Nestjs Developers","item":"https://daily.dev/squads/nestjsdevs"},{"@type":"ListItem","position":3,"name":"Day 2/30 — Keep Controllers Thin"}]}
```

