Generate comprehensive documentation for Express.js routing patterns, methods, and middleware based on official Express.js routing documentation.
Generate comprehensive documentation for Express.js routing patterns, middleware, and request handling based on the official Express.js routing guide.
This skill creates detailed documentation covering Express.js routing concepts including:
When a user requests Express.js routing documentation, follow these steps:
1. **Determine Scope**
- Ask which routing topics to cover (or generate comprehensive guide)
- Identify if documentation is for Express 4.x or 5.x (note version differences)
- Determine target audience level (beginner, intermediate, advanced)
2. **Structure the Documentation**
Create sections in this order:
- Introduction to routing and endpoint concepts
- Route methods (`app.get()`, `app.post()`, `app.all()`, etc.)
- Route paths (string literals, patterns, regex)
- Route parameters (`:userId`, `:id(\\d+)`, etc.)
- Route handlers (single, multiple, arrays, combinations)
- Response methods (`res.send()`, `res.json()`, etc.)
- `app.route()` for chainable handlers
- `express.Router()` for modular routing
- Best practices and migration notes (if relevant)
3. **Include Code Examples**
For each concept, provide:
- Minimal working example
- Real-world use case
- Expected request URL and response
- `req.params` object structure (for parameterized routes)
4. **Add Version-Specific Notes**
- Highlight Express 5.x changes (pattern matching, regex handling)
- Include migration warnings where applicable
- Reference deprecated syntax with modern alternatives
5. **Document Response Methods**
Create a table with:
- Method name
- Description
- Example usage
- When to use it
6. **Provide Middleware Examples**
- Show route-specific middleware
- Demonstrate `next()` usage
- Explain `next('route')` for bypassing handlers
7. **Include Routing Best Practices**
- Modular route organization
- Router naming conventions
- Path parameter validation
- Error handling in routes
**User Request:** "Document Express.js route parameters"
**Generated Documentation:**
```markdown
Route parameters are named URL segments used to capture values from the request URL. Values are available in `req.params`.
```javascript
app.get('/users/:userId/books/:bookId', (req, res) => {
res.send(req.params)
})
```
**Request:** `http://localhost:3000/users/34/books/8989`
**Response:** `{ "userId": "34", "bookId": "8989" }`
```javascript
app.get('/user/:userId(\\d+)', (req, res) => {
res.send(`User ID: ${req.params.userId}`)
})
```
**Request:** `http://localhost:3000/user/42`
**Response:** `"User ID: 42"`
⚠️ **Express 4.x Note:** Escape backslashes (`\\d+` not `\d+`)
```
1. **Route Methods:** `get`, `post`, `put`, `delete`, `all`, `use`
2. **Path Patterns:** Literal strings, wildcards (`?`, `+`, `*`), regex
3. **Parameters:** Named segments (`:param`), regex constraints
4. **Handlers:** Single callbacks, arrays, middleware chains
5. **Router Class:** Modular route organization with `express.Router()`
6. **Response API:** `send()`, `json()`, `redirect()`, `render()`, etc.
Generate clear, actionable documentation with runnable code examples that developers can immediately use in their Express.js applications.
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/expressjs-routing-guide/raw