nodejs-backend-patterns

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

1|Updated Jun 30, 2026
One-click install
npx skills add https://github.com/trutoman/Conjuros --skill nodejs-backend-patterns-trutoman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nodejs-backend-patterns
Source: https://github.com/trutoman/Conjuros/tree/main/.agents/skills/nodejs-backend-patterns
Command: npx skills add https://github.com/trutoman/Conjuros --skill nodejs-backend-patterns-trutoman

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Building Node.js backends from scratch involves repeated decisions about project structure, middleware ordering, error handling, and database access, and inconsistent choices lead to fragile APIs that are hard to test and maintain. ## Core Features & Use Cases - Layered Architecture Templates: Provides controller, service, and repository layer implementations in TypeScript with dependency injection wiring. - Middleware & Error Handling: Includes JWT authentication, Zod validation, Redis-backed rate limiting, structured Pino logging, and a global error handler with custom error classes. - Database & Auth Patterns: Covers PostgreSQL connection pooling, Mongoose models, transaction handling, JWT access/refresh token flows, and Redis caching. - Use Case: When scaffolding a new REST API, apply the layered structure with the validation middleware and global error handler to get consistent request handling across all routes from day one. ## Quick Start Ask the AI to scaffold a Node.js Express API with layered architecture, JWT authentication, and centralized error handling 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 API with layered architecture?

Separate the codebase into controllers handling HTTP requests, services containing business logic, and repositories managing data access. Wire them together with a dependency injection container so each layer depends on abstractions and remains testable.

How to implement JWT authentication middleware in Express?

Extract the Bearer token from the Authorization header, verify it with jsonwebtoken against your JWT secret, and attach the decoded payload to the request object. Pair short-lived 15-minute access tokens with 7-day refresh tokens for session continuity.

Express vs Fastify for Node.js backend development?

Express offers a minimalist, widely adopted middleware ecosystem, while Fastify provides higher throughput with built-in schema validation and Pino logging. Both patterns in this skill use TypeScript with helmet, cors, and compression.

How do I handle errors centrally in an Express application?

Define custom error classes extending a base AppError with status codes, then register a global error-handling middleware as the last middleware. It returns structured JSON for known errors and logs unexpected ones without leaking details in production.

Does this pattern support both PostgreSQL and MongoDB?

Yes, it includes a PostgreSQL repository using the pg Pool with parameterized queries and transactions, plus a Mongoose setup with connection management and schema indexes. Both use connection pooling and graceful shutdown handling.

How do I add rate limiting to Node.js API endpoints?

Use express-rate-limit with a Redis store via rate-limit-redis so limits persist across instances. Apply a general limiter for API routes and a stricter one for authentication endpoints, skipping successful requests on auth routes.