nodejs-backend-patterns
wshobson/agents
Build production-ready Node.js backends with Express/Fastify, middleware patterns, authentication, and database integration.
What is nodejs-backend-patterns?
Comprehensive guidance for building scalable, maintainable Node.js backend applications using modern frameworks and architectural patterns. Use this when creating REST APIs, GraphQL servers, microservices, or implementing authentication, error handling, and database integration.
- Implement middleware patterns and error handling strategies
- Set up authentication and authorization flows
- Design REST APIs and GraphQL backends
- Integrate SQL and NoSQL databases with connection pooling
- Build microservices architectures with proper separation of concerns
- Implement real-time features using WebSockets
How to install nodejs-backend-patterns
npx skills add https://github.com/wshobson/agents --skill nodejs-backend-patterns- Node.js runtime environment
- Basic knowledge of Express or Fastify frameworks
- Understanding of HTTP and REST concepts
How to use nodejs-backend-patterns
- 1.Review the best practices section to understand core principles like TypeScript usage, error handling, and environment configuration
- 2.Read `references/details.md` for detailed pattern documentation and worked examples
- 3.Choose your framework (Express or Fastify) and implement middleware patterns for your use case
- 4.Set up input validation, authentication, and authorization layers
- 5.Configure database integration with connection pooling
- 6.Implement structured logging and monitoring
- 7.Add rate limiting, CORS, and security headers
- 8.Write unit, integration, and E2E tests using the `javascript-testing-patterns` skill
Use cases
- Creating a REST API with Express or Fastify with proper error handling and validation
- Building a GraphQL server with authentication and database integration
- Designing a microservices architecture with multiple Node.js services
- Implementing user authentication with JWT and session management
- Setting up a real-time chat or notification system with WebSockets
- Backend engineers building Node.js applications
- Full-stack developers creating server-side logic
- DevOps engineers designing microservices architectures
- Teams implementing production-grade API services
nodejs-backend-patterns FAQ
Both are valid; Express has a larger ecosystem and community, while Fastify offers better performance and modern defaults. Choose based on your performance requirements and team familiarity.
Create custom error classes, use consistent error response formats, implement try-catch blocks or promise error handlers, and log errors with context for debugging.
Use JWT tokens for stateless APIs, implement refresh token rotation, store tokens securely, validate on every protected route, and consider OAuth2 for third-party integrations.
Use connection pooling to manage database connections efficiently, implement query builders or ORMs for type safety, use transactions for multi-step operations, and add proper error handling for database failures.
Detailed pattern documentation and worked examples are available in the `references/details.md` file included with this skill.
Full instructions (SKILL.md)
Source of truth, from wshobson/agents.
name: nodejs-backend-patterns description: Build production-ready Node.js backend services with Express/Fastify, implementing middleware patterns, error handling, authentication, database integration, and API design best practices. Use when creating Node.js servers, REST APIs, GraphQL backends, or microservices architectures.
Node.js Backend Patterns
Comprehensive guidance for building scalable, maintainable, and production-ready Node.js backend applications with modern frameworks, architectural patterns, and best practices.
When to Use This Skill
- Building REST APIs or GraphQL servers
- Creating microservices with Node.js
- Implementing authentication and authorization
- Designing scalable backend architectures
- Setting up middleware and error handling
- Integrating databases (SQL and NoSQL)
- Building real-time applications with WebSockets
- Implementing background job processing
Detailed patterns and worked examples
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
Best Practices
- Use TypeScript: Type safety prevents runtime errors
- Implement proper error handling: Use custom error classes
- Validate input: Use libraries like Zod or Joi
- Use environment variables: Never hardcode secrets
- Implement logging: Use structured logging (Pino, Winston)
- Add rate limiting: Prevent abuse
- Use HTTPS: Always in production
- Implement CORS properly: Don't use
*in production - Use dependency injection: Easier testing and maintenance
- Write tests: Unit, integration, and E2E tests
- Handle graceful shutdown: Clean up resources
- Use connection pooling: For databases
- Implement health checks: For monitoring
- Use compression: Reduce response size
- Monitor performance: Use APM tools
Testing Patterns
See javascript-testing-patterns skill for comprehensive testing guidance.
Related skills
More from wshobson/agents and the wider catalog.

nx-workspace-patterns
Configure and optimize Nx monorepo workspaces with production patterns for project boundaries, caching, and affected commands.

on-call-handoff-patterns
Master on-call shift handoffs with structured context transfer and escalation procedures.

openapi-spec-generation
Generate and maintain OpenAPI 3.1 specifications from code, design-first specs, and validation patterns.

parallel-debugging
Debug complex issues systematically using competing hypotheses and parallel investigation.

parallel-feature-development
Coordinate parallel feature development with file ownership strategies and conflict avoidance rules for multi-agent teams.

paypal-integration
Integrate PayPal payments with express checkout, subscriptions, and refund management.