mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-19 16:55:02 +02:00
Move the generic ResponseError hierarchy (BadRequestError, NotFoundError, ForbiddenError, ...) into @n8n/backend-services and point every cli import at the package root. 29 backend modules import these classes. Feature-specific response errors (MFA codes, license EULA, credential and workflow transfer, webhook not found, workflow activation and validation) stay in cli next to the code that throws them. They extend the generic classes from the package. WorkflowPublishBlockedError moves because three modules import it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| src | ||
| eslint.config.mjs | ||
| package.json | ||
| README.md | ||
| tsconfig.build.json | ||
| tsconfig.json | ||
| vite.config.ts | ||
@n8n/backend-services
Backend services and HTTP error classes that many backend modules share.
Why this package exists
Backend modules live in packages/cli/src/modules/<name> today. Most of them
import a small set of services from the rest of cli. A module cannot move
into its own workspace package while those imports point at @/... paths in
cli.
This package is the home for that shared set. It sits above @n8n/db and
below n8n (cli) in the dependency graph:
flowchart TD
cli["n8n (cli) and backend modules"] --> sc["@n8n/backend-services"]
sc --> db["@n8n/db"]
sc --> bc["@n8n/backend-common"]
db --> bc
@n8n/backend-common holds the foundation that @n8n/db also needs (logger,
license state, module registry, locks). @n8n/backend-services holds business
and infrastructure services that need the persistence layer or that only
cli and the modules consume.
What lives here
| Export | Purpose |
|---|---|
ResponseError and its subclasses (BadRequestError, NotFoundError, ForbiddenError, ...) |
Errors that map to an HTTP status code in a REST response |
Rules for adding code
- The code must not import from
n8n(cli). If it needs acliseam, define a narrow DI port here and bind it incliat bootstrap. - At least two backend modules must use the code. A service that one module uses belongs to that module.
- Keep the file layout of
cli(errors/,services/). A move withgit mvkeeps the history readable. - Add each new export to
src/index.ts. Consumers import from the package root only.