
Implement a global exception filter in NestJS to standardize json error responses by extracting http status and message from exceptions, with an internal server error, and register it in main.
Learn how to implement logging for a NestJS API using Winston, capturing every request and error to diagnose production issues, with options between console logs and external libraries.
Set up winston logging in NestJS by installing winston and Nest. Create a logger module and configure console and file transports with timestamped json logs and error log.
Register the custom Winston logger by overwriting the NestJS default logger, add a logging interceptor, and log request, response, and errors with a unique request id.
Install the uuid package and implement a middleware to generate and attach a request id for each incoming request, preventing undefined request ids in debug mode.
Explore defense layers for a NestJS and Prisma backend, implementing helmet, rate limiting, and body size limits, plus region-based whitelists, to protect APIs from brute-force and payload attacks.
Install helmet and throttling, register helmet in main.ts by importing helmet, and disable the content security policy for api-only apps.
Apply helmet headers to secure the api by adding x-frame-options, x-content-type-options, and referrer-policy, then verify locally at localhost:3000 with a curl test.
Implement rate limiting in the backend by restricting requests per time window. Configure the throttle module globally with ttl 900 seconds (15 minutes) and a limit of 100 requests.
Configure global throttling in NestJS by setting TTL and per-minute limits with the global throttle module and application-level guard, and apply endpoint-specific limits on login in the auth controller.
Test rate limiting by sending multiple login requests, observe throttle exceptions after five requests per minute, and understand the 'too many requests' and 'please wait' responses.
Explore Swagger documentation for a powerful api with many endpoints as a growing project expands beyond 20 endpoints, and learn how Swagger helps document them.
Understand how swagger and the open api spec expose routes, request bodies, parameters, and responses with interactive documentation, and learn to integrate swagger into NestJS and Prisma.
Install swagger and set up swagger docs in a NestJS app using the document builder, configuring title, description, version, and JWT auth, with the UI at api/docs.
Learn to document a create task endpoint with dto properties, API decorators, Swagger tags, and protected routes using jwt auth.
Open the invitation, accept it, and validate the invite flow to confirm the local environment works with Ethereal.
Refactor NestJS backend mailer by replacing node mailer with the recent email service, configure production and development API keys, and test sending emails.
integrate resend into the NestJS and Prisma backend masterclass, wiring the resend api key via config service, creating a resend client, and sending invite emails from the email service.
Execute the deployment plan by hosting the backend on railway, with or without docker, and deploy the database first on neon (a Postgres cloud option) for a Node.js application.
Create neon and vercel accounts, set up neon postgres integration on the free plan, copy the connection string to env, then run prisma migrate dev and prisma generate.
Set up a free tier railway account, install the railway CLI, and deploy a new project via CLI, with railway handling docker; tidy env files and refactor main.ts before deployment.
Create a health route by generating a health controller module, defining a get route that returns status okay, and confirming a dedicated health module.
Update the package.json to add production scripts, including pre-start and port handling, and run prisma migrate deploy plus npx prisma generate, with node env set to production.
Practice integration testing by validating the controller, service, and Prisma db work together through a Postgres database, creating a user and a team, and verifying Prisma writes to the database.
Set up a test Postgres database with Docker Compose, a dedicated test network, and health checks, and isolate it from production and dev databases using a bridge network.
Configure jest as the testing framework for the NestJS and Prisma backend by creating a dedicated config file and setting up dotenv for the testing environment.
Set up Jest test automation by creating a setup script, loading test envs with dotenv, running migrations via child_process, and orchestrating test db up, migrate, and down with docker compose.
Change the tsconfig file to set resolve js module to true and enable the json module.
Identify and fix the regular expression issue, ensure it starts correctly and includes common and dot star. Verify configuration, module paths, and logs for the common email service.
Learn to unit test a Prisma create method in a NestJS backend by mocking Prisma team create with Jest and asserting the create call data.
Initiate an end-to-end test in NestJS by creating a teams.controller.integration.spec.ts, wire up app and Prisma service, implement login for a protected route with bcrypt.
Fix an integration test by correcting init usage, updating chest config and transform ignore patterns for node_modules, and ensure the test passes with a new team ID in the database.
Write an end-to-end test for the teams flow, including sign up and login, JWT token setup, and complete flow validation, with beforeAll/beforeEach and afterEach/afterAll hooks and Prisma constraints.
Run an end-to-end test to verify that deleting a team requires removing team members first, ensuring the function is called correctly and end-to-end and integration tests pass.
Discover why background jobs with bull mq decouple heavy tasks from synchronous api requests, enabling fast responses, reliable retries, and scalable scheduling for emails, pdfs, and large media.
Install Redis to support bull MQ by updating docker-compose with a Redis service, image version 6, and a data volume, then run docker-compose up to verify port 6379.
Install the MQ dependencies, pull MQ, and add the iris redis package after confirming Postgres and Dradis are running to start Redis.
Initialize and register the BullMQ module, configure the Redis host and port, set up the email cue queue, and export the queue module for external use.
Master NestJS and Prisma backend concepts by building an email queue with a producer and consumer, processing welcome emails via a worker triggered by the auth controller.
Learn how to configure BullMQ email delivery in NestJS by exporting the email consumer and provider, wiring an email service, and testing delayed emails with Postman and Recent API.
Open the inbox to review a test email and welcome message from the test API, and learn to schedule high-intensity tasks using a pull MQ queue.
The Complete NestJS & Prisma Backend Masterclass (Part 2: Advanced Practices, Security, & Testing Mastery)
Does Your Code Pass the Professional Test?
You've built the foundation in Part 1, but now it's time to elevate your code to Senior Engineer standards. Are you tired of manually testing features? Does your application crash under heavy load? Can your API handle sensitive data securely? This course is where you master the practices that separate junior coders from high-paid, production-focused developers.
This course confronts the essential realities of professional software development:
"I don't know how to guarantee my code works without breaking something else."
Solution: You will master Unit, Integration, and E2E Testing with Jest and Supertest, ensuring bulletproof code quality.
"My application is slow because I run heavy tasks in the main thread."
Solution: You will implement a powerful BullMQ Queue System for managing asynchronous tasks, boosting application performance and resilience.
"I worry about exposing sensitive internal data through the API."
Solution: You will enforce data integrity and strict privacy using Zod Schemas and advanced Serialization techniques.
What You Will Achieve—The Professional Backend Toolkit
By completing Part 2, you will own a professional toolkit that proves your expertise in performance and stability:
Master Testing APIS: Implement exhaustive testing strategies (Unit, Integration, E2E) for all core features.
Performance Engineering: Integrate and manage Asynchronous Job Queues with BullMQ, ensuring your application remains fast and responsive.
Data Integrity: Secure your API boundaries by implementing Zod for Input Validation and advanced Class Transformer Serialization for outbound data.
Advanced Features: Implement sophisticated features like Notifications Management and User Settings that rely on these new resilient structures.
Build Stable, High-Performance Code
Stop writing code that might work. Start writing code you can guarantee works. If you're ready to add testing, performance tuning, and bulletproof security practices to your skill set, this is the course you need.
Enroll now and transform your functional code into professional, reliable software!