Migrating to 0.4
This guide covers the breaking changes introduced in ergo 0.4.0 and
ergo-router 0.4.0, released together on 2026-06-06. Both packages must
be upgraded in lockstep — ergo-router 0.4.x requires @centralping/ergo >=0.4.0 <0.5.0.
Prerequisites
Section titled “Prerequisites”npm install @centralping/ergo@^0.4.0 @centralping/ergo-router@^0.4.0Verify versions after install:
npm ls @centralping/ergo @centralping/ergo-routerBreaking: Composition Format (ergo + ergo-router)
Section titled “Breaking: Composition Format (ergo + ergo-router)”Middleware composition changed from [fn, setPath] tuples to {fn, setPath}
config objects. This affects both standalone compose() pipelines and
ergo-router declarative configs that use the use key.
Before (0.3.x)
Section titled “Before (0.3.x)”import { compose, logger, url, accepts } from "@centralping/ergo";
const pipeline = compose( [logger(), "log"], [accepts({ types: ["application/json"] }), "accepts"], [url(), "url"], (req, res, acc) => ({ response: { body: { path: acc.url.pathname } }, }),);router.get("/items", { use: [ [customAudit(), "audit"], ], execute: (req, res, acc) => ({ response: { body: acc.audit }, }),});After (0.4.x)
Section titled “After (0.4.x)”import { compose, logger, url, accepts } from "@centralping/ergo";
const pipeline = compose( { fn: logger(), setPath: "log" }, { fn: accepts({ types: ["application/json"] }), setPath: "accepts" }, { fn: url(), setPath: "url" }, (req, res, acc) => ({ response: { body: { path: acc.url.pathname } }, }),);router.get("/items", { use: [ { fn: customAudit(), setPath: "audit" }, ], execute: (req, res, acc) => ({ response: { body: acc.audit }, }),});What changed: normalizeOp() now discriminates via typeof op === 'function'
instead of Array.isArray. Response-only middleware (cors, securityHeaders,
cacheControl, rateLimit, precondition, validate, jsonApiQuery) remain plain
functions — no wrapper needed.
Migration Steps
Section titled “Migration Steps”- Find all tuple usages — search for
[followed by a function call and a string literal in your pipeline compositions. - Replace each tuple —
[myFn(), 'key']becomes{fn: myFn(), setPath: 'key'}. - Leave response-only middleware unchanged — middleware that does not write
to the domain accumulator (e.g.,
validate(...),rateLimit(...)) stays as a plain function call.
Cumulative Changes from Earlier Versions
Section titled “Cumulative Changes from Earlier Versions”If you are upgrading from a version earlier than 0.3.x, the following breaking changes also apply. Apply them in order.
From 0.2.x: Paginate Export Shape (ergo 0.3.0)
Section titled “From 0.2.x: Paginate Export Shape (ergo 0.3.0)”The paginate export from @centralping/ergo changed from the
lib/paginate.js utility namespace to the http/paginate.js factory function.
Before (0.2.x):
import { paginate } from "@centralping/ergo";
const { offset, limit } = paginate.parseOffsetParams(query);After (0.3.x+):
import { parseOffsetParams } from "@centralping/ergo/lib/paginate";
const { offset, limit } = parseOffsetParams(query);The paginate name on the main export is now the pipeline middleware factory.
Low-level helpers (parseOffsetParams, parseCursorParams, offsetResponse,
cursorResponse) moved to the deep import path.
From 0.1.x: Config Key Rename (ergo-router 0.2.0)
Section titled “From 0.1.x: Config Key Rename (ergo-router 0.2.0)”The auth config key was renamed to authorization for consistency with the
authorization() middleware factory name.
Before (0.1.x):
router.get("/users", { auth: { strategies: [bearerStrategy] }, execute: handler,});After (0.2.x+):
router.get("/users", { authorization: { strategies: [bearerStrategy] }, execute: handler,});Verification
Section titled “Verification”After migrating, confirm everything works:
- Build passes —
npm run build(or your project’s build command) exits without errors. - Tests pass —
npm testexits without failures. - No runtime warnings — ergo 0.4.1+ validates option keys at factory time
and emits
process.emitWarningfor unknown keys. Check for warnings during startup. - Review changelog — see the full ergo changelog and ergo-router changelog for non-breaking additions you may want to adopt.