nodejs-backend-patterns

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

2|Updated Feb 15, 2026
One-click install
npx skills add https://github.com/SkinnnyJay/simpill-utils --skill nodejs-backend-patterns-skinnnyjay
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nodejs-backend-patterns
Source: https://github.com/SkinnnyJay/simpill-utils/tree/main/.agents/skills/nodejs-backend-patterns
Command: npx skills add https://github.com/SkinnnyJay/simpill-utils --skill nodejs-backend-patterns-skinnnyjay

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building production-grade Node.js backends requires coordinating many concerns—framework setup, middleware, error handling, authentication, database access, and caching—and getting any of them wrong leads to security holes, crashes, and unmaintainable code. ## Core Features & Use Cases - Framework Setup: Ready-to-use Express and Fastify configurations with security middleware (helmet, CORS, compression) and schema-validated routes. - Layered Architecture: Complete controller-service-repository pattern with dependency injection container for testable, maintainable codebases. - Security & Reliability: JWT authentication with refresh tokens, role-based authorization, Zod validation middleware, Redis-backed rate limiting, and centralized error handling with custom error classes. - Use Case: When scaffolding a new REST API for a user management service, apply this Skill to generate the full stack: typed routes, a PostgreSQL repository with connection pooling, bcrypt password hashing, JWT login flow, and a global error handler. ## Quick Start Use the nodejs-backend-patterns skill to scaffold an Express REST API with JWT authentication, PostgreSQL integration, and centralized error handling.

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 separating controllers (HTTP handling), services (business logic), and repositories (data access). Wire dependencies through a DI container so each layer can be tested and replaced independently.

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

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

How to implement JWT authentication with refresh tokens in Node.js?▼

Verify credentials with bcrypt, then sign a short-lived access token (15 minutes) and a long-lived refresh token (7 days) with separate secrets. The refresh endpoint validates the refresh token and issues a new access token.

Does Express error handling catch async errors automatically?▼

No, Express does not catch rejected promises from async handlers by default. Wrap handlers in an asyncHandler utility that forwards rejections to next(), then centralize responses in a global error-handling middleware.

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

Acquire a dedicated client from the pg Pool, issue BEGIN, run all related queries on that client, then COMMIT. On any error, ROLLBACK and always release the client in a finally block to avoid pool exhaustion.

Why use Redis for rate limiting instead of in-memory stores?▼

In-memory rate limiters reset on restart and do not share state across multiple server instances. A Redis-backed store via rate-limit-redis keeps counters consistent in horizontally scaled deployments.