Express.js REST API

Standardize Express.js REST API structure into routes, controllers, services, and models.

1|Updated May 2, 2026
One-click install
npx skills add https://github.com/Levironexe/architect --skill express-js-rest-api
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Express.js REST API
Source: https://github.com/Levironexe/architect/tree/main/skills/stacks/express-api
Command: npx skills add https://github.com/Levironexe/architect --skill express-js-rest-api

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Express REST APIs often degrade into tightly coupled route handlers where HTTP concerns, business rules, and data access get mixed together, making safe refactors risky and code reviews slow.

Core Features & Use Cases

  • Layered routing and request handling: keeps endpoint definitions in src/routes, translates req/res in src/controllers, and delegates pure work to services.
  • Business logic and data access separation: moves rules into src/services and persistence into src/models so storage changes don’t ripple through the app.
  • Consistent middleware structure: centralizes cross-cutting concerns like validation and error handling in src/middleware, including AppError-based error responses.

Quick Start

Tell your coding agent: "Given my Express project, restructure it into routes/controllers/services/models with centralized middleware and apply the separation rules from the Express.js REST API skill."

Frequently Asked Questions about Express.js REST API

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I separate business logic from route handlers in an Express.js REST API?

To separate business logic in an Express.js REST API, move HTTP concerns into controllers, pure rules into services, and persistence into models, keeping route handlers clean and preventing tightly coupled code.

What is the best way to structure Express.js REST API folders for maintainability?

The best way to structure an Express.js REST API is organizing code into src/routes, src/controllers, src/services, src/models, and src/middleware to prevent mixed HTTP, business, and persistence logic.

How do I implement centralized error handling in an Express.js REST API?

Centralized error handling in an Express.js REST API is implemented by placing cross-cutting concerns in src/middleware and using AppError-based responses to enforce consistent error handling across the codebase.

Can I refactor existing Express.js endpoints without breaking the current API structure?

Yes, you can refactor existing Express.js endpoints by migrating mixed logic into a layered design with storage-agnostic services and dependency injection, ensuring safe refactoring without coupling req/res objects.

Why does my Express.js service layer have direct dependencies on req and res objects?

Express.js service layers couple to req and res because of mixed logic; refactoring into storage-agnostic services free of HTTP coupling via dependency injection ensures pure business rules and safe changes.

Does this layered architecture approach work for new Express.js REST APIs as well as legacy ones?

Yes, this layered architecture standardizes Express.js REST API structure for both implementing new endpoints and refactoring existing APIs, enforcing consistent middleware and separation rules across any codebase.