Node.js Express Server

Node.js Express Server

Guides a coding agent in building production-ready Express.js servers with routing, middleware chains, JWT authentication, error handling and database integration.

Skill files9 files

references/

scripts/

SKILL.md103 lines
1
---
2
name: nodejs-express-server
3
description: >
4
Build production-ready Express.js servers with middleware, authentication,
5
routing, and database integration. Use when creating REST APIs, managing
6
requests/responses, implementing middleware chains, and handling server logic.
7
---
8
9
# Node.js Express Server
10
11
## Table of Contents
12
13
- [Overview](#overview)
14
- [When to Use](#when-to-use)
15
- [Quick Start](#quick-start)
16
- [Reference Guides](#reference-guides)
17
- [Best Practices](#best-practices)
18
19
## Overview
20
21
Create robust Express.js applications with proper routing, middleware chains, authentication mechanisms, and database integration following industry best practices.
22
23
## When to Use
24
25
- Building REST APIs with Node.js
26
- Implementing server-side request handling
27
- Creating middleware chains for cross-cutting concerns
28
- Managing authentication and authorization
29
- Connecting to databases from Node.js
30
- Implementing error handling and logging
31
32
## Quick Start
33
34
Minimal working example:
35
36
```javascript
37
const express = require("express");
38
const app = express();
39
const PORT = process.env.PORT || 3000;
40
41
// Middleware
42
app.use(express.json());
43
app.use(express.urlencoded({ extended: true }));
44
45
// Routes
46
app.get("/health", (req, res) => {
47
res.json({ status: "OK", timestamp: new Date().toISOString() });
48
});
49
50
// Error handling
51
app.use((err, req, res, next) => {
52
console.error(err.stack);
53
res.status(err.status || 500).json({
54
error: err.message,
55
requestId: req.id,
56
});
57
});
58
59
app.listen(PORT, () => {
60
console.log(`Server running on port ${PORT}`);
61
});
62
```
63
64
## Reference Guides
65
66
Detailed implementations in the `references/` directory:
67
68
| Guide | Contents |
69
|---|---|
70
| [Basic Express Setup](references/basic-express-setup.md) | Basic Express Setup |
71
| [Middleware Chain Implementation](references/middleware-chain-implementation.md) | Middleware Chain Implementation |
72
| [Database Integration (PostgreSQL with Sequelize)](references/database-integration-postgresql-with-sequelize.md) | Database Integration (PostgreSQL with Sequelize) |
73
| [Authentication with JWT](references/authentication-with-jwt.md) | Authentication with JWT |
74
| [RESTful Routes with CRUD Operations](references/restful-routes-with-crud-operations.md) | RESTful Routes with CRUD Operations |
75
| [Error Handling Middleware](references/error-handling-middleware.md) | Error Handling Middleware |
76
| [Environment Configuration](references/environment-configuration.md) | Environment Configuration |
77
78
## Best Practices
79
80
### ✅ DO
81
82
- Use middleware for cross-cutting concerns
83
- Implement proper error handling
84
- Validate input data before processing
85
- Use async/await for async operations
86
- Implement authentication on protected routes
87
- Use environment variables for configuration
88
- Add logging and monitoring
89
- Use HTTPS in production
90
- Implement rate limiting
91
- Keep route handlers focused and small
92
93
### ❌ DON'T
94
95
- Handle errors silently
96
- Store sensitive data in code
97
- Use synchronous operations in routes
98
- Forget to validate user input
99
- Implement authentication in route handlers
100
- Use callback hell (use promises/async-await)
101
- Expose stack traces in production
102
- Trust client-side validation only
103

© AJ Geddes · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 13,330 prompts

More by @OpenSourceBuffGuy

See all
Valentine's newspaper editorial portrait from your photo prompt image

Valentine's newspaper editorial portrait from your photo

Turns an uploaded face photo into a top-down Valentine's fashion editorial: red blazer, roses, heart balloons and a newspaper headline.

image-prompt, nano-banana, reference-image, face-reference, photo-editing, portrait, woman, fashion-shoot, editorial, valentines-day, photorealistic, studio-lighting, close-up, high-angle, film-grain, vibrant-colors, flowers, text-rendering, placeholders, fashion, holiday, soft-lighting, bokeh, vertical-format

Woman leaps into leaf pile revealing pool prompt image

Woman leaps into leaf pile revealing pool

Generates a one-shot autumn gag where someone announces the first day of fall and leaps into a leaf pile that hides a tiny blue kiddie pool.

video-prompt, comedy, autumn, single-take, wide-shot, golden-hour, vibrant-colors, humorous, timed-beats, lip-sync, natural-light, short-form-video, quick, cinematic, action, transformation

Seaside morning vlog from bedroom to terrace prompt image

Seaside morning vlog from bedroom to terrace

Generates a 15-second vertical seaside vlog of a woman waking up, stepping onto a terrace and speaking to camera, with a beat for every second and written dialogue.

video-prompt, vlog, timed-beats, multi-shot, lip-sync, short-form-video, vertical-format, selfie, ocean, travel, natural-light, golden-hour, character-consistency, handheld, camera-movement, cinematic, photorealistic, woman, hailuo, for-content-creators, long-form, structured-output, bokeh, summer, text-to-video

Reviews

Loading reviews…

Discussion

Loading comments…