NestJSでzodを使う!基本的な使い方を整理してみた。 - Qiita

はじめに TypeScriptでのフルスタック開発ではzodを使うことがデファクトっぽい。(?) 初めてzodを使ったので、備忘録として基本的な使い方をまとめてみました。 目次 スキーマと型の一元管理 DTOの自動生成 バリデーションの実装 PrismaなどのORMと...

Qiita

Day 7
✅ 24 test suites, 153 tests passing.

Solid coverage across service and controller layers in my modular monorepo. Strict typing (TypeScript), full DTO validation, and realistic mocks across complex relations (TypeORM).

Next: fine-tuning error handling & exploring e2e strategies.

https://write.as/bmariusz/24-test-suites-153-tests-passing-scaling-confidence-with-every-assertion

#TypeScript #NestJS #Nextjs #InsuranceTech #Microservices #monorepo #rbac #codingdays #swagger #jwt #jwt_auth #programming

Day#7: 24 Test Suites, 153 Tests Passing — Scaling Confidence with Every Assertion

After several days of shaping a growing service architecture, I've finally reached a point where 24 test suites and 153 individual tests ...

Mariusz Balewski

Day 6
TL;DR: Groups, memberships, hierarchy — all dynamic now.

Released backend v0.3.0 🎉

✅ Users can belong to multiple groups with typed roles
✅ Groups can form hierarchical or overlapping structures
✅ Roles are normalized via reference types

Built with NestJS + TypeORM. Documented via Swagger.

https://write.as/bmariusz/building-a-flexible-group-structure-with-nestjs-and-typeorm

#TypeScript #NestJS #Nextjs #InsuranceTech #Microservices #monorepo #rbac #codingdays #swagger #jwt #jwt_auth #programming

Building a Flexible Group Structure with NestJS and TypeORM

TL;DR: I introduced a generic group model into the backend to handle dynamic user-to-organization assignments and relationships. Users ca...

Mariusz Balewski

Day 5
TL;DR: Continued work on backend security — role-based access is now fully wired up.

✅ Got fine-grained role-based access control fully working today.

• Roles loaded from PostgreSQL
• Injected into JWT during login
• Validated via custom `@Roles()` + `RolesGuard`
• Authenticated via `@UseGuards(JwtAuthGuard)` globally
• Introduced `@Public()` decorator to bypass guards for public endpoints
• Swagger supports Bearer token for testing

Took a while to get the role propagation into the token right — the key was enriching the `validateUser()` result, not just fetching data from DB.

Modular, clean, and no magic. Feels good. 👌

more on: https://write.as/bmariusz/continuation-securing-routes-with-jwt-and-role-based-access-control
#CloudNative #TypeScript #NestJS #Nextjs #InsuranceTech #Microservices #monorepo
#codingdays #swagger #jwt #jwt_auth #programming

Continuation: Securing Routes with JWT and Role-Based Access Control

TL;DR: Continuing development on the backend platform — this time focusing on securing routes with JWT, implementing @Roles decorators, h...

Mariusz Balewski

In #nestjs we declare path components on `@Controller(<path>)` and method decorators like `@Get(<path>)`, `@Post(<path>)`, etc.

But it's also possible to declare a "path prefix" which applies to all controllers in the module via `RouterModule`:

`RouterModule.register({path: '/foo', module: MyModule});`

100K юзеров за 3 дня — что сломалось после релиза

Привет, Хабр! В этой статье — история запуска Telegram Mini App, куда за трое суток пришло 100.000 реальных пользователей. Покажу, как мы масштабировали Node.js приложения на многоядерных серверах, увеличивали RPS в 10 раз, боролись с N+1 проблемой в MongoDB и снижали нагрузку на CPU. А ещё расскажу как мы быстро настроили мониторинг через Grafana, подключили Cloudflare и интегрировали Sentry. Поделюсь практическими инсайтами о том, на что стоит обращать внимание в первую очередь, и как эти инструменты помогли нам оперативно находить узкие места и устранять сбои в реальном времени. Всё, о чём будет в этой статье, основано на том, что действительно сработало. Кроме того, расскажу, какие моменты мы упустили до запуска. Это разбор с цифрами, графиками и практическими выводами. Он может сэкономить вам время, нервы и деньги, если вы готовитесь к запуску Telegram Mini App или просто работаете с Node.js-приложениями, которые могут оказаться под серьёзной нагрузкой. Это вторая часть истории — про то, как мы запустились и что сломалось первым после релиза. Тут будет про то, как мы это чинили и какие решения приняли, чтобы приложение продолжало работать под нагрузкой. Первая часть про подготовку к запуску доступна здесь .

https://habr.com/ru/articles/916502/

#telegram #telegram_mini_app #nodejs #nextjs #nestjs #mongodb #нагрузочное_тестирование #масштабирование #docker #cloudflare

100K юзеров за 3 дня — что сломалось после релиза

Привет, Хабр! В этой статье — история запуска Telegram Mini App, куда за трое суток пришло 100.000 реальных пользователей. Покажу, как мы масштабировали Node.js приложения на многоядерных серверах,...

Хабр

Day 4

TL;DR: Full Swagger docs + JWT auth with registration and login are live.

Today’s work focused on two key improvements.

1. Swagger documentation was extended across all API layers. DTOs, entities, and controllers were enriched with `@ApiTags`, `@ApiOperation`, `@ApiResponse`, and detailed `@ApiBody` annotations — including real-life examples for request bodies.

2. JWT-based authentication was implemented. A secure registration flow was added, with password hashing via bcrypt. A login endpoint now issues access tokens containing user ID, email, and roles. All logic is encapsulated using Passport strategies (local and JWT). The next step will be protecting routes with guards and role-based access.

#CloudNative #TypeScript #NestJS #Nextjs #InsuranceTech #Microservices #monorepo
#codingdays #swagger #jwt #jwt_auth #programming

Day 3 2/2
2. Enabling API documentation with Swagger.

I integrated Swagger into the backend (NestJS v10, ESM, Turbo monorepo), using `@nestjs/swagger@7` to match our current framework version.
The docs are now live at `/api/docs`, fully aligned with our global `ValidationPipe` and `AllExceptionsFilter` — ensuring consistent validation and error responses.

Next: annotate DTOs, describe endpoints properly, and restrict access.
#CloudNative #TypeScript #NestJS #Nextjs #InsuranceTech #Microservices
#codingdays #programming

Day 2:

TL;DR:
❌ `composite: true`
❌ `tsconfig.build.json`
✅ `paths` in `tsconfig.base.json`
✅ `include` shared libs explicitly where needed
✅ `turbo run build` just works

Wrestled for hours (~3) with TypeScript `project references` and `paths` in a Turbo monorepo (NestJS, ESM).
Turns out: if you want global aliases like `@my-lib/foo` to *just work* across apps — skip `composite: true` and `tsc --build`.

Project references and alias-based path mapping don't mix well when your intent is to keep things simple.

#CloudNative #TypeScript #NestJS #Nextjs #InsuranceTech #Microservices
#codingdays #programming

Day 1:
tl;dr: ESM + TS + NestJS + TypeORM is possible, but not recommended for the impatient.

Successfully bootstrapped NestJS + TypeORM + PostgreSQL stack using ESM.

It only took:
- 6 hours
- 17 cryptic errors
- 3 existential crises

Turns out, using modern JS modules with legacy decorators is... bold. But hey — it runs now.

#CloudNative #TypeScript #NestJS #Nextjs #InsuranceTech #Microservices
#codingdays #programming