Generates Express.js API routes with proper middleware, error handling, validation, and TypeScript support. Use when creating REST APIs or Express endpoints.
Generates production-ready Express.js REST APIs with proper layering, validation, and error handling.
This skill creates Express.js APIs with:
cp examples/intermediate/framework-skills/express-api-generator/SKILL.md \
.claude/skills/express-api-generator.md
Ask Claude to create Express APIs naturally:
"create Express API for user management"
"generate REST endpoints for products with CRUD"
"build authentication API with Express and JWT"
When you ask: "create Express API for managing blog posts"
Claude will generate a complete API structure:
routes/posts.ts:
import { Router } from 'express'
import { PostController } from '../controllers/PostController'
import { validatePost } from '../middleware/validation'
import { authenticate } from '../middleware/auth'
const router = Router()
const controller = new PostController()
router.get('/', controller.list)
router.get('/:id', controller.getById)
router.post('/', authenticate, validatePost, controller.create)
router.put('/:id', authenticate, validatePost, controller.update)
router.delete('/:id', authenticate, controller.delete)
export default router
controllers/PostController.ts:
import { Request, Response, NextFunction } from 'express'
import { PostService } from '../services/PostService'
import { ApiError } from '../utils/ApiError'
export class PostController {
private service: PostService
constructor() {
this.service = new PostService()
}
list = async (req: Request, res: Response, next: NextFunction) => {
try {
const { page = 1, limit = 10, search } = req.query
const posts = await this.service.findAll({
page: Number(page),
limit: Number(limit),
search: search as string
})
res.json(posts)
} catch (error) {
next(error)
}
}
getById = async (req: Request, res: Response, next: NextFunction) => {
try {
const post = await this.service.findById(req.params.id)
if (!post) {
throw new ApiError(404, 'Post not found')
}
res.json(post)
} catch (error) {
next(error)
}
}
create = async (req: Request, res: Response, next: NextFunction) => {
try {
const post = await this.service.create({
...req.body,
authorId: req.user.id
})
res.status(201).json(post)
} catch (error) {
next(error)
}
}
update = async (req: Request, res: Response, next: NextFunction) => {
try {
const post = await this.service.update(req.params.id, req.body)
res.json(post)
} catch (error) {
next(error)
}
}
delete = async (req: Request, res: Response, next: NextFunction) => {
try {
await this.service.delete(req.params.id)
res.status(204).send()
} catch (error) {
next(error)
}
}
}
middleware/validation.ts:
import { Request, Response, NextFunction } from 'express'
import Joi from 'joi'
const postSchema = Joi.object({
title: Joi.string().required().min(3).max(200),
content: Joi.string().required(),
tags: Joi.array().items(Joi.string()),
published: Joi.boolean().default(false)
})
export const validatePost = (req: Request, res: Response, next: NextFunction) => {
const { error } = postSchema.validate(req.body, { abortEarly: false })
if (error) {
return res.status(400).json({
message: 'Validation failed',
errors: error.details.map(d => ({
field: d.path.join('.'),
message: d.message
}))
})
}
next()
}
npx skills add Dexploarer/express-api-generator下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer