nodejs-backend-patterns

Guide Node.js backend development with Express.js and Fastify patterns.

6|Updated Mar 24, 2023
One-click install
npx skills add https://github.com/GaoZimeng0425/nemo-cli --skill nodejs-backend-patterns-gaozimeng0425
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nodejs-backend-patterns
Source: https://github.com/GaoZimeng0425/nemo-cli/tree/main/.claude/skills/nodejs-backend-patterns
Command: npx skills add https://github.com/GaoZimeng0425/nemo-cli --skill nodejs-backend-patterns-gaozimeng0425

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires express, fastify, helmet, cors, compression, bcrypt, jsonwebtoken, redis, pino-pretty, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill unit provides comprehensive guidance for building scalable, maintainable, and production-ready Node.js backend applications using modern frameworks and best practices.

Core Features & Use Cases

  • Framework Guidance: Offers setup and usage instructions for Express.js and Fastify.
  • Architectural Patterns: Introduces layered architecture and dependency injection.
  • Middleware Patterns: Includes authentication, validation, rate limiting, and logging middleware.
  • Error Handling: Demonstrates custom error classes and a global error handler.
  • Database Patterns: Covers PostgreSQL and MongoDB integration with connection pooling and Mongoose.
  • Authentication & Authorization: Explains JWT authentication and refresh tokens.
  • Caching Strategies: Introduces Redis for caching and a cache decorator.
  • API Response Format: Defines a structured API response format.
  • Best Practices: Lists 15 best practices for Node.js backend development.
  • Testing Patterns: References external testing guidance.
  • Resources: Provides links to additional resources for Node.js development.

Quick Start

Use the nodejs-backend-patterns skill to set up a new Express.js server with basic security and logging.

Frequently Asked Questions about nodejs-backend-patterns

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

FAQPage Schema
How do I implement JWT authentication and refresh tokens in a Node.js backend?

JWT authentication and refresh tokens in Node.js are implemented using jsonwebtoken to issue access tokens and securely rotate refresh tokens. This Skill provides specific patterns for structuring authentication middleware and managing token lifecycles.

What is the best way to structure Express.js middleware for validation and rate limiting?

Express.js middleware for validation and rate limiting is best structured as modular, reusable functions injected into the request lifecycle. This Skill demonstrates specific patterns for applying middleware globally and per-route to enforce security policies.

How do I set up a global error handler and custom error classes in Fastify?

Global error handling in Fastify involves defining custom error classes and capturing exceptions centrally to standardize API response formats. This Skill offers guidance on implementing these patterns to ensure consistent error propagation across your backend.

Can I use Redis for caching and connection pooling with PostgreSQL in Node.js?

Redis caching and PostgreSQL connection pooling can be integrated together in Node.js to optimize database queries. This Skill covers implementing a cache decorator and managing connection pools to reduce latency and database load.

Does this Node.js backend pattern guidance include security configurations like helmet and cors?

Node.js backend pattern guidance includes security configurations using helmet and cors to secure HTTP headers and control cross-origin requests. These dependencies are explicitly required to set up a production-ready server with basic security protocols.

How do I standardize API response formats across Express.js and Fastify applications?

Standardizing API response formats across Express.js and Fastify requires defining a structured schema for success and error outputs. This Skill defines a consistent API response format to ensure predictable client-side data consumption.