home / skills / partme-ai / full-stack-skills / express

express skill

/skills/express

This skill guides you in building Express.js apps with routing, middleware, templating, and REST APIs for practical backend development.

npx playbooks add skill partme-ai/full-stack-skills --skill express

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
681 B
---
name: express
description: Provides comprehensive guidance for Express.js framework including routing, middleware, request handling, templating, and API development. Use when the user asks about Express, needs to create Express applications, set up routes, implement middleware, or build REST APIs.
license: Complete terms in LICENSE.txt
---

## When to use this skill

Use this skill whenever the user wants to:
- [待完善:根据具体工具添加使用场景]

## How to use this skill

[待完善:根据具体工具添加使用指南]

## Best Practices

[待完善:根据具体工具添加最佳实践]

## Keywords

[待完善:根据具体工具添加关键词]

Overview

This skill provides comprehensive, practical guidance for building applications with the Express.js framework. It covers routing, middleware, request/response handling, templating, error handling, and REST API design to help you create robust server-side JavaScript apps. Use it to accelerate development, follow best practices, and troubleshoot common Express patterns.

How this skill works

The skill inspects your goals and current code context, then offers targeted examples, configuration snippets, and step-by-step instructions for Express tasks. It generates route handlers, middleware templates, error-handling patterns, and sample API endpoints, and advises on security, performance, and deployment considerations. It adapts recommendations to common stacks like Node.js, npm/yarn, and popular templating engines or JSON APIs.

When to use it

  • Scaffolding a new Express app and setting up basic routes and server configuration
  • Implementing middleware for logging, authentication, input validation, or CORS
  • Designing and documenting RESTful APIs with pagination, filtering, and versioning
  • Integrating templating engines (EJS, Pug) or serving static assets
  • Debugging request/response flow, error handling, or performance bottlenecks

Best practices

  • Keep middleware small and focused; compose reusable middleware for concerns like auth and validation
  • Validate and sanitize all incoming data, and centralize error handling with an error middleware
  • Use route-level modularization (Express Router) and separate concerns by feature
  • Prefer async/await and handle promise rejections to avoid unhandled errors
  • Limit middleware order dependencies and document middleware side effects clearly

Example use cases

  • Create a REST API with CRUD endpoints, input validation, and JSON responses
  • Add authentication middleware using JWTs and protect specific routes
  • Serve a single-page app by configuring static assets and a catch-all route
  • Implement request logging, rate limiting, and CORS for a public API
  • Migrate callback-based handlers to async/await and centralize error responses

FAQ

Should I use Express for new Node.js APIs?

Yes—Express is lightweight, widely supported, and flexible. It remains a solid choice for APIs and server-rendered apps, especially when you want minimal abstraction and full control.

How do I structure a large Express app?

Organize by feature: use Express Router per resource, separate controllers, services, and middleware, and keep configuration and bootstrapping isolated from business logic.

How do I handle async errors in Express?

Use async/await and wrap route handlers with a small wrapper that forwards errors to next(), or use a library to auto-catch promise rejections and delegate to centralized error middleware.