u/UneditedTips

NestJS Error Handling: Stop Sending Ugly 500 Errors to Your Users
▲ 1 r/nestjs

NestJS Error Handling: Stop Sending Ugly 500 Errors to Your Users

One of the first things I do on any new NestJS project now is set up a global exception filter. Took me too long to make this a habit.

Without one, your error responses are inconsistent. A NotFoundException returns { statusCode, message, error }. An unexpected database error returns { statusCode, message } with no error field. A validation error returns { message: string[] } with an array instead of a string. Your frontend has to handle three different shapes just to display an error message.

A global exception filter fixes all of that in one place. You define the shape once, every error in the entire app goes through it, and the response always looks the same.

What confuses beginners is the difference between HttpException and a plain JavaScript Error. If you throw new Error('something') in a service, the filter can't extract a useful status code or message it just logs the stack trace and returns a 500. Always use NestJS's built-in exceptions (NotFoundException, BadRequestException, etc.) or you can also extend HttpException for custom ones.

brandfordtech.com
u/UneditedTips — 12 hours ago
▲ 7 r/nestjs+1 crossposts

Synchronize: true destroyed a production database: Here's the migration setup that prevents it

I used synchronize: true in a NestJS project for way longer than I should have. It was fine in development. But when I renamed a column in an entity, pushed to production, and TypeORM dropped the old column and created a new one on the next restart., data was gone.

You can fix this with migrations, but the TypeORM + NestJS migration setup is very confusing because the TypeORM CLI doesn't know about NestJS's dependency injection. You end up needing two configs, one for AppModule, one for the CLI, and getting them to share the same values without duplicating everything takes a bit of work.

The piece that finally made it click for me was the data-source.ts file. It's a standalone TypeORM DataSource that reads from your .env directly, no NestJS involved. The CLI uses that. NestJS uses ConfigService in AppModule. Both point to the same database, same entities, same migrations folder.

reddit.com
u/UneditedTips — 4 days ago
▲ 12 r/nestjs

Connecting NestJS to PostgreSQL with TypeORM — including the parts most tutorials skip

The NestJS + TypeORM setup isn’t hard once you’ve done it, but there are a few things nobody tells you upfront that cost you an hour when you hit them.
Here’s a full guide in my article

brandfordtech.com
u/UneditedTips — 5 days ago

If NestJS architecture confuses you coming from Express, here's how I think about it

NestJS looks complicated when you're used to Express. Modules, Providers, Controllers, services, Guards, Interceptors, it's a lot of new vocabulary for what feels like the same thing.

Here's how I broke it down in my head:

Express gives you a blank canvas, NestJS gives you a template.

The template is: one module per feature, one controller per module for HTTP, one service per module for logic. That's the whole pattern.

The module is just metadata, it tells the framework what exists and how things connect. The controller is your route handler, nothing else. The service is where your actual code lives.

Once I stopped trying to understand it all at once and just followed the pattern, everything else started to make sense.

reddit.com
u/UneditedTips — 7 days ago
▲ 1 r/Backend+1 crossposts

Switching from Express to NestJS? Here's exactly what changes (and what doesn't)

A lot of Express devs look at NestJS and immediately think it's over-engineered decorators everywhere, a module system, controllers, services, all this boilerplate just to return some JSON.

I thought the same thing. Then I realized NestJS isn't replacing Express, it's literally running on top of it. Under the hood, it's still an Express server. The same req and res objects. The same middleware model. The same Node.js HTTP behavior.

brandfordtech.com
u/UneditedTips — 8 days ago
▲ 27 r/dotnet

Transitioning From C# To Typescript

How easy is it to learn typescript as someone who is already familiar with C# ?

reddit.com
u/UneditedTips — 9 days ago

Nest Js Architecture

When I first opened a NestJS project, I genuinely thought someone had over-complicated what should be a simple Node.js API.
app.module.ts, app.controller.ts, app.service.ts, a NestFactory in main.ts, and I hadn’t written a single route yet. I was coming from Express, where you just use app.get('/users', handler) and move on, this felt like a lot of code for not much.
What changed it for me was realizing NestJS isn’t adding complexity for fun. It’s giving you the structure that large Express apps always end up building anyway, just upfront, before things get out of hand.
What are your opinions ?

reddit.com
u/UneditedTips — 10 days ago
▲ 10 r/Backend

What is your opinion about NestJS ?

I'll like to find out your opinions about Nestjs when it comes to ennterprise applications ?

reddit.com
u/UneditedTips — 10 days ago