nodejs-backend-patterns

Scaffold Express or Fastify Node.js backends with layered architecture and JWT auth.

Updated Apr 11, 2026
One-click install
npx skills add https://github.com/BrunoAlpezdev/lluvia-de-ideas --skill nodejs-backend-patterns-brunoalpezdev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nodejs-backend-patterns
Source: https://github.com/BrunoAlpezdev/lluvia-de-ideas/tree/main/.agents/skills/nodejs-backend-patterns
Command: npx skills add https://github.com/BrunoAlpezdev/lluvia-de-ideas --skill nodejs-backend-patterns-brunoalpezdev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It solves the difficulty of building and maintaining production-ready Node.js backend services by providing proven architecture, middleware, validation, and error-handling patterns.

Core Features & Use Cases

  • Framework-ready server setup: Express and Fastify patterns for security middleware, CORS, compression, logging, and request body handling.
  • Scalable architecture blueprint: Layered structure (controllers, services, repositories, middleware, routes, config, types) to keep code maintainable as it grows.
  • Production-grade request pipeline: Authentication/authorization middleware, input validation with Zod/Joi-style schemas, rate limiting (optionally Redis-backed), and consistent request logging.
  • Reliable error handling: Custom operational error classes plus a global error handler and async error wrapper to avoid unhandled promise issues.
  • Database & auth foundations: SQL connection pooling patterns (PostgreSQL/pg), MongoDB connection patterns, transactions, JWT auth with access/refresh tokens, caching with Redis, and standardized API responses.

Quick Start

Use the nodejs-backend-patterns skill to scaffold an Express or Fastify REST API design for a production environment with authentication, validation, rate limiting, database integration, and a consistent error/response format.

Frequently Asked Questions about nodejs-backend-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a production-ready Node.js backend with Express or Fastify?

A production-ready Node.js backend uses a layered architecture with separate controllers, services, and repositories to maintain code as it scales. This pattern enforces deterministic request flows and standardized API responses for Express and Fastify.

What is the best way to handle errors in a Node.js REST API?

The best way to handle errors in a Node.js REST API is using custom operational error classes with a global error handler and async wrapper. This prevents unhandled promise rejections and ensures consistent API error responses.

How do I implement JWT authentication with access and refresh tokens in Node.js?

JWT authentication with access and refresh tokens in Node.js is implemented via dedicated authentication and authorization middleware. This secures the request pipeline by validating tokens before passing requests to the service layer.

Does this Node.js backend pattern support both PostgreSQL and MongoDB database connections?

Yes, this Node.js backend pattern supports both PostgreSQL and MongoDB. It provides SQL connection pooling patterns for PostgreSQL and specific connection patterns for MongoDB, including database transactions.

Can I use Redis for rate limiting and caching in my Node.js API?

Yes, you can use Redis for rate limiting and caching in your Node.js API. The production-grade request pipeline supports optionally Redis-backed rate limiting and Redis caching foundations to protect endpoints and improve response times.

How do I validate request body input in a Fastify or Express API?

Request body input validation in Express or Fastify is handled using Zod or Joi-style schemas within the request pipeline. This ensures data integrity before the payload reaches your core service layer or database integration logic.