nodejs-backend-patterns
wshobson/agents
Build production-ready Node.js backends with Express/Fastify, middleware patterns, auth, and database integration.
What is nodejs-backend-patterns?
Comprehensive guidance for building scalable, maintainable Node.js backend applications. Covers REST APIs, GraphQL servers, microservices, authentication, error handling, database integration, and modern architectural patterns. Use when creating Node.js servers, APIs, or microservices architectures.
- 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
- Implement real-time features with WebSockets
How to install nodejs-backend-patterns
npx skills add https://github.com/wshobson/agents --skill nodejs-backend-patternsHow to use nodejs-backend-patterns
- 1.Review the best practices section for foundational patterns
- 2.Consult references/details.md for in-depth pattern documentation
- 3.Choose your framework (Express or Fastify) based on performance needs
- 4.Implement TypeScript for type safety in your codebase
- 5.Set up environment variables for configuration management
- 6.Configure structured logging using Pino or Winston
- 7.Implement input validation with Zod or Joi
- 8.Add authentication and authorization middleware
Use cases
- Building REST APIs with Express or Fastify frameworks
- Creating GraphQL servers with proper schema design
- Implementing microservices with inter-service communication
- Setting up authentication systems with JWT or session-based approaches
- Designing scalable database architectures with proper pooling
- Backend developers building Node.js services
- Full-stack developers creating server-side logic
- DevOps engineers designing microservices architectures
- Teams building production-grade APIs
- Developers transitioning to Node.js from other platforms
nodejs-backend-patterns FAQ
Both are production-ready. Express has larger ecosystem and community; Fastify offers better performance and modern defaults. Choose based on your performance requirements and team familiarity.
Use custom error classes, implement centralized error handling middleware, log errors with context, and return appropriate HTTP status codes. Never expose internal error details to clients.
Use JWT for stateless APIs and microservices, or session-based auth for traditional web apps. Always use HTTPS in production and never hardcode secrets.
Use connection pooling to manage database connections efficiently. Configure pool size based on expected concurrent requests and database limits.
Detailed pattern documentation and worked examples are 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.
tailwind-design-system
Build production-ready design systems with Tailwind CSS v4, design tokens, and component libraries.
typescript-advanced-types
Master TypeScript's advanced type system: generics, conditional types, mapped types, and utility types for type-safe applications.
python-performance-optimization
Profile and optimize Python code using cProfile, memory profilers, and performance best practices.
brand-landingpage
Brand-first landing page designer with guided interviews and Stitch-powered iteration.
python-testing-patterns
Implement comprehensive testing strategies with pytest, fixtures, mocking, and test-driven development.
api-design-principles
Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs.