nodejs-backend-patterns

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

Updated May 28, 2026
One-click install
npx skills add https://github.com/qbstabletampa-creator/firmware-foundation-studios --skill nodejs-backend-patterns-qbstabletampa-creator
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nodejs-backend-patterns
Source: https://github.com/qbstabletampa-creator/firmware-foundation-studios/tree/main/archive/apps/manna-catch/.agents/skills/nodejs-backend-patterns
Command: npx skills add https://github.com/qbstabletampa-creator/firmware-foundation-studios --skill nodejs-backend-patterns-qbstabletampa-creator

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building production Node.js backends requires many decisions around framework choice, project structure, error handling, authentication, and database access. This Skill provides proven TypeScript patterns and working code for each of these concerns so you avoid reinventing fragile boilerplate. ## Core Features & Use Cases - Framework Setup: Ready-to-use Express and Fastify server configurations with security middleware (helmet, CORS, compression) and schema-validated routes. - Layered Architecture: Complete controller, service, and repository layer implementations with dependency injection container wiring. - Middleware & Error Handling: JWT authentication, Zod validation, Redis-backed rate limiting, structured Pino logging, and a global error handler with custom error classes. - Use Case: When scaffolding a new REST API with user authentication and PostgreSQL storage, apply these patterns to get a typed, validated, rate-limited service with connection pooling and graceful shutdown. ## Quick Start Ask the AI to scaffold a Node.js Express API with JWT authentication, Zod validation, and a PostgreSQL repository layer using these backend patterns.

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 Express backend project?▼

Use a layered architecture with separate directories for controllers, services, repositories, models, middleware, and routes. Controllers handle HTTP requests, services contain business logic, and repositories manage data access, wired together through a dependency injection container.

Express vs Fastify for Node.js APIs, which should I use?▼

Express is a minimalist framework with a large middleware ecosystem suited for general APIs. Fastify offers higher performance, built-in Pino logging, and type-safe routes with JSON schema validation, making it better for performance-critical services.

How do I implement JWT authentication in Express middleware?▼

Create middleware that extracts the Bearer token from the authorization header, verifies it with jsonwebtoken against your JWT secret, and attaches the decoded payload to the request object. Use short-lived access tokens (15 minutes) with 7-day refresh tokens.

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

Acquire a client from the pg Pool, run BEGIN, execute your queries, then COMMIT on success or ROLLBACK on error inside a try-catch block. Always release the client in a finally block to return it to the connection pool.

Does Express rate limiting work across multiple server instances?▼

The default in-memory store does not share state between instances. Use express-rate-limit with rate-limit-redis and an ioredis client so all instances enforce limits against a shared Redis store.

Why should I use Zod for request validation in Node.js?▼

Zod provides schema-based validation that parses request body, query, and params before they reach your controller. Validation errors can be mapped to field-level messages and returned as structured 400 responses through a validation middleware.