Node.js Backend Patterns

Node.js Backend Patterns

Guides an agent in building production-ready Node.js backends with Express or Fastify: middleware, error handling, auth, databases and API design.

Skill files3 files

references/

SKILL.md46 lines
1
---
2
name: nodejs-backend-patterns
3
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.
4
---
5
6
# Node.js Backend Patterns
7
8
Comprehensive guidance for building scalable, maintainable, and production-ready Node.js backend applications with modern frameworks, architectural patterns, and best practices.
9
10
## When to Use This Skill
11
12
- Building REST APIs or GraphQL servers
13
- Creating microservices with Node.js
14
- Implementing authentication and authorization
15
- Designing scalable backend architectures
16
- Setting up middleware and error handling
17
- Integrating databases (SQL and NoSQL)
18
- Building real-time applications with WebSockets
19
- Implementing background job processing
20
21
## Detailed patterns and worked examples
22
23
Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
24
25
## Best Practices
26
27
1. **Use TypeScript**: Type safety prevents runtime errors
28
2. **Implement proper error handling**: Use custom error classes
29
3. **Validate input**: Use libraries like Zod or Joi
30
4. **Use environment variables**: Never hardcode secrets
31
5. **Implement logging**: Use structured logging (Pino, Winston)
32
6. **Add rate limiting**: Prevent abuse
33
7. **Use HTTPS**: Always in production
34
8. **Implement CORS properly**: Don't use `*` in production
35
9. **Use dependency injection**: Easier testing and maintenance
36
10. **Write tests**: Unit, integration, and E2E tests
37
11. **Handle graceful shutdown**: Clean up resources
38
12. **Use connection pooling**: For databases
39
13. **Implement health checks**: For monitoring
40
14. **Use compression**: Reduce response size
41
15. **Monitor performance**: Use APM tools
42
43
## Testing Patterns
44
45
See `javascript-testing-patterns` skill for comprehensive testing guidance.
46

© Seth Hobson · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…