nodejs-backend-patterns

Implements Node.js backend services with Express, Fastify, middleware, authentication, and database patterns.

Updated Mar 14, 2026
One-click install
npx skills add https://github.com/Ishaq74/atomic --skill nodejs-backend-patterns-ishaq74
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nodejs-backend-patterns
Source: https://github.com/Ishaq74/atomic/tree/main/.github/skills/nodejs-backend-patterns
Command: npx skills add https://github.com/Ishaq74/atomic --skill nodejs-backend-patterns-ishaq74

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building a production Node.js backend requires many decisions—framework choice, project structure, error handling, authentication, database access—and getting any of them wrong leads to fragile, hard-to-maintain services. This Skill provides proven architectural patterns and working TypeScript code so you can scaffold a well-structured backend without reinventing each layer. ## Core Features & Use Cases - Framework Setup: Ready-to-use Express and Fastify server configurations with security middleware (helmet, CORS, compression) and structured logging via Pino. - Layered Architecture: Complete controller-service-repository implementation with dependency injection, custom error classes, and a global error handler. - Auth, Validation & Infrastructure: JWT authentication with refresh tokens, Zod validation middleware, Redis-backed rate limiting and caching, PostgreSQL connection pooling, and transaction handling. - Use Case: You need to build a REST API for a user management system. Use this Skill to generate the layered structure, wire up JWT auth, add Zod input validation, and configure a pooled PostgreSQL connection with proper transaction support. ## Quick Start Use the nodejs-backend-patterns skill to scaffold an Express REST API with layered architecture, JWT authentication, and PostgreSQL integration.

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 Node.js backend with Express and TypeScript?

Use a layered architecture with controllers handling HTTP requests, services containing business logic, and repositories managing data access. Wire the layers together with a dependency injection container and add a global error handler for consistent error responses.

Express vs Fastify for building REST APIs?

Express offers a minimalist, widely adopted middleware ecosystem, while Fastify provides higher performance with built-in schema validation and Pino logging. Both setups in this Skill include helmet, CORS, and compression for security and response handling.

How do I implement JWT authentication in Node.js?

Use short-lived access tokens (15 minutes) signed with a JWT secret, paired with 7-day refresh tokens. Verify passwords with bcrypt, attach the decoded payload to the request in an authentication middleware, and protect routes with role-based authorization.

How do I handle database transactions in PostgreSQL with Node.js?

Acquire a client from the pg connection pool, run BEGIN, execute your queries, then COMMIT on success or ROLLBACK on error, always releasing the client in a finally block. This keeps multi-step writes like order creation atomic.

How do I add rate limiting to an Express API?

Use express-rate-limit with a Redis store via rate-limit-redis so limits persist across instances. Apply a general limiter (e.g., 100 requests per 15 minutes) globally and a stricter limiter on authentication endpoints.

When should I use Redis caching in a Node.js backend?

Use Redis caching for frequently read, rarely changing data to reduce database load. The CacheService pattern supports get, set with TTL, delete, and pattern-based invalidation, plus a Cacheable decorator for method-level caching.