원클릭으로
express
Express.js routing, middleware, and error handling. Trigger: When building REST APIs or server logic with Express.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Express.js routing, middleware, and error handling. Trigger: When building REST APIs or server logic with Express.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Paste-ready session summary for context transfer to a new chat. Trigger: User says 'context handoff', 'start fresh', or session needs to continue.
One-at-a-time questioning to fully profile a goal before acting. Trigger: User says 'grill me', goal is vague, or clarification is needed first.
Batch execution with checkpoints. Trigger: When executing plans with batched tasks.
Universal coding principles: DRY, security by default, null guards, and YAGNI. Trigger: When writing or reviewing code in any language or technology.
Accessibility guide (WCAG 2.1/2.2, Level A–AAA). Trigger: When building UI components, interactive elements, or auditing accessibility compliance.
Astro quality patterns: island philosophy, SEO by page type, and Core Web Vitals. Trigger: When reviewing Astro site quality or hydration decisions.
| name | express |
| description | Express.js routing, middleware, and error handling. Trigger: When building REST APIs or server logic with Express. |
| license | Apache 2.0 |
| metadata | {"version":"1.1","type":"framework","skills":["nodejs"],"dependencies":{"express":">=4.18.0 <5.0.0"}} |
REST APIs and server logic with Express v4.x middleware and routing.
Don't use for:
Group routes into Router instances for clean app.ts.
// CORRECT: modular router in routes/users.ts
const router = Router();
router.get("/", listUsers);
router.post("/", createUser);
export default router;
// WRONG: all routes dumped directly in app.ts
Express 4 doesn't catch rejected promises. Wrap async handlers.
// CORRECT: wrapper forwards rejections to error middleware
const asyncHandler = (fn: RequestHandler): RequestHandler =>
(req, res, next) => Promise.resolve(fn(req, res, next)).catch(next);
router.get("/users/:id", asyncHandler(async (req, res) => {
const user = await db.findUser(req.params.id);
if (!user) throw new NotFoundError("User not found");
res.json(user);
}));
Single error handler as last middleware in stack.
// CORRECT: 4-argument signature signals error middleware
const errorHandler: ErrorRequestHandler = (err, req, res, next) => {
const status = err.statusCode ?? 500;
res.status(status).json({ error: err.message });
};
app.use(errorHandler);
// WRONG: try/catch in every route returning res.status(500)
Validate bodies before route logic.
const CreateUser = z.object({ name: z.string(), email: z.string().email() });
const validate = (schema: z.ZodSchema): RequestHandler =>
(req, res, next) => {
const result = schema.safeParse(req.body);
if (!result.success) return res.status(400).json(result.error.flatten());
req.body = result.data;
next();
};
Return correct HTTP codes per operation.
// CORRECT: 201 for creation, 204 for no-content delete
router.post("/users", asyncHandler(async (req, res) => {
const user = await db.createUser(req.body);
res.status(201).json(user);
}));
router.delete("/users/:id", asyncHandler(async (req, res) => {
await db.deleteUser(req.params.id);
res.status(204).end();
}));
Multiple resource routes?
→ Group into a Router per resource
Async handler?
→ Wrap with asyncHandler utility
Need auth?
→ Add auth middleware before route handlers
Input from client?
→ Validate with schema middleware
Creating a resource?
→ Return 201, not 200
Deleting a resource?
→ Return 204 with no body
Unhandled error?
→ Let centralized error middleware respond
import express from "express";
import { z } from "zod";
const app = express();
app.use(express.json());
const asyncHandler = (fn: Function) =>
(req: any, res: any, next: any) => Promise.resolve(fn(req, res, next)).catch(next);
const UserSchema = z.object({ name: z.string(), email: z.string().email() });
app.get("/users/:id", asyncHandler(async (req: any, res: any) => {
const user = await db.findUser(req.params.id);
if (!user) return res.status(404).json({ error: "Not found" });
res.json(user);
}));
app.post("/users", asyncHandler(async (req: any, res: any) => {
const data = UserSchema.parse(req.body);
res.status(201).json(await db.createUser(data));
}));
express.json({ limit: "1mb" }) to prevent 413/memory issues.res.json() twice throws; guard with if (res.headersSent).Content-Type: application/json → empty req.body.app.use callexpress.json() has an explicit size limit