---
name: patrones-backend-nodejs
description: Guia de referencia para construir servicios backend Node.js de produccion con Express/Fastify, incluyendo middleware, autenticacion, integracion de bases de datos y diseno de APIs. Aplica para REST APIs, GraphQL, microservicios y aplicaciones en tiempo real.
license: MIT
metadata:
  id: b6f7d671
  slug: patrones-backend-nodejs
  titulo: "Patrones de Backend con Node.js"
  servicio: Web
  categoria_recurso: Web-Desarrollo
  tipo: referencia
  nivel: avanzado
  idioma: es
  idioma_original: en
  acceso: gratis
  precio_eur: 0
  plataformas: [Node.js, Express, Fastify, GraphQL, TypeScript]
  dependencias: [javascript-testing-patterns]
  licencia: { spdx: MIT, redistribuible: true, uso_comercial: true }
  fuente:
    repo: wshobson/agents
    url: https://github.com/wshobson/agents/tree/main/plugins/javascript-typescript/skills/nodejs-backend-patterns
    commit: cc37bfd
    autor: wshobson
    nombre_original: nodejs-backend-patterns
    duplicados_en: []
  seguridad: { veredicto: seguro, riesgo: bajo, escaneado: "2026-06-14", motor: "grep-estatico+auditor-llm" }
  ficha:
    que_hace: "Proporciona patrones y buenas practicas para construir backends Node.js escalables y listos para produccion."
    como_lo_hace: "Documenta patrones de middleware, manejo de errores, autenticacion, integracion de bases de datos y arquitectura de APIs con Express y Fastify."
  content_hash: "b6f7d6718e28664b7f837f10f803b23fdacbf430fb1505559387403467df4048"
  version: 1.0.0
---

# 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

1. **Use TypeScript**: Type safety prevents runtime errors
2. **Implement proper error handling**: Use custom error classes
3. **Validate input**: Use libraries like Zod or Joi
4. **Use environment variables**: Never hardcode secrets
5. **Implement logging**: Use structured logging (Pino, Winston)
6. **Add rate limiting**: Prevent abuse
7. **Use HTTPS**: Always in production
8. **Implement CORS properly**: Don't use `*` in production
9. **Use dependency injection**: Easier testing and maintenance
10. **Write tests**: Unit, integration, and E2E tests
11. **Handle graceful shutdown**: Clean up resources
12. **Use connection pooling**: For databases
13. **Implement health checks**: For monitoring
14. **Use compression**: Reduce response size
15. **Monitor performance**: Use APM tools

## Testing Patterns

See `javascript-testing-patterns` skill for comprehensive testing guidance.
