Skip to content

Upgrading to 0.7 ​

Moost 0.7.0 builds on wooks 0.8. All moost / @moostjs/* packages share one version: upgrade them together, and upgrade @prostojs/wf to ^0.3.1 if your app lists it (^0.3.0 up to 0.7.5), so it shares one copy with @moostjs/event-wf. This page is a checklist; each item links to the page that documents the current behaviour. The full list is in the changelog; the wooks side is in the wooks 0.8.0 changelog.

Check these in your app ​

Interceptors ​

  • After and error hooks now run as one chain over the current value, innermost first: each hook sees what the previous one replied, a throw switches the rest of the chain to error hooks, and a non-Error reply() recovers it.
  • An outer error-only hook (logger, audit trail) no longer sees an error that an inner CATCH_ERROR hook recovered — read the third argument original (class-based: useInterceptOriginal()) in its after hook.
  • An outer after envelope now also wraps error bodies that an error hook replied with.

Details and examples: The after/error chain.

HTTP ​

  • Default status: PUT, PATCH and DELETE with a body answer 200 (were 201 / 202 / 202). Add @SetStatus() where clients rely on the old codes. → Setting status codes. @moostjs/swagger documents the same defaults → Swagger responses.
  • Durations are seconds: a numeric cookie maxAge or Cache-Control maxAge is seconds (was milliseconds); bare digit strings like '3600' now throw. Remove any * 1000. → Setting cookies.
  • Error responses are never cacheable: they carry Cache-Control: no-store, also replacing a cache-control set with @SetHeader(…, { when: 'error' | 'always' }). → Setting headers.
  • Conditional requests: a GET/HEAD 200 with an ETag or Last-Modified now answers 304 / 412 automatically, also when the handler set the ETag. → Conditional requests.
  • Proxies are untrusted by default: @Ip({ trustProxy: true }) is deprecated and now trusts one hop (the right-most X-Forwarded-For entry). Configure trustProxy on MoostHttp and use @Ip(). → IP address.
  • @Query() resolves {} instead of undefined when there is no query string. → Query parameters.
  • Programmatic fetch() / request() outside a request has an unknown client address (@Ip() is '', was 127.0.0.1). On a fetch runtime pass the peer: http.fetch(req, { remoteAddress }). → Serving a fetch runtime.

@moostjs/vite ​

  • An unmatched route under prefix returns Moost's JSON 404 (after a static-file attempt for GET/HEAD) instead of the SPA shell or SSR page. prefixFallthrough: true keeps the old behaviour. → Middleware Mode.
  • sirv is a regular dependency now — you can drop it from your own dependencies if you added it only for the generated server.

Workflows ​

  • Trigger refusals are thrown HttpErrors with a code (WF_EXPIRED, WF_FORBIDDEN, …) and reach your error interceptors; the text moved from body.error to body.message. Clients reading body.message ?? body.error work with both. → Access control and refusals.
  • allow: [] admits nothing (it allowed everything), and allow / block also apply on resume.
  • Run scopes: every run releases its DI scope when it ends or pauses, whoever starts it. Up to and including 0.7.2, a createOutletHandler(wooksWf) built before new MoostWf(wooksWf) missed the release; since 0.7.3 (on @wooksjs/event-wf 0.8.1) the order no longer matters. → getWfApp().

Shutdown ​

  • app.dispose() awaits in-flight runDetached runs before the dispose hooks, and ignores hooks registered after dispose() was called. → Application Dispose.

New in 0.7 ​

  • app.runDetached(name, fn) — background work with its own event scope; app.addDisposeHook(fn).
  • @Locale(), useLocale(), setTranslator() / useTranslate() — per-event locale and a translation hook for your own i18n library.
  • Error code and params on HttpError bodies, and transformErrorBody on MoostHttp.
  • MoostWf.mint() (headless start that returns a resume token), resolveSchemaId(), and the trigger hooks around, beforePersist, renderEnvelope, restoreOnError → Outlets configuration.
  • 0.7.5: the workflow trigger's resumeOnly list, per-field wording and pathPrefix: false for translated error bodies, trustProxy: { addresses, hops } (client IP), and a warning when two apps share one Wooks router.
  • 0.7.6: when a paused state expires — strategy.expiresAtFor(), resolveExpiresAt.
  • 0.7.7 (on @wooksjs/event-wf 0.8.4): the workflow trigger's startOnly list (started here, never resumed) and the beforeResume hook (refuse a resume before the token is consumed).
  • 0.7.8 (on wooks 0.8.5):
    • @moostjs/vite: the headers option (middleware mode) sets headers on every response (pages, SPA shell, static files, routes) in dev and production; an SSR render can return a CSP nonce; createSSRServer().use() middlewares now run before routes, files and pages in dev too (they ran after Vite's own middlewares and the SSR page), and a failing one (next(error), a throw, a rejection) fails the request instead of the process — see Custom Server Entry.
    • The route-drop warning also fires when a subclass without @Inherit() re-declares only some of its ancestor's routes, and names the dropped ones. You may see new warnings on upgrade: add @Inherit(), re-declare the routes, or mark a deliberate drop with @Inherit(false).
    • @moostjs/event-http re-exports DEFAULT_FORWARD_HEADERS and securityHeaders(), so apps need no direct @wooksjs/event-http import for them.
    • HttpError bodies keep statusCode, message and error typed after error instanceof HttpError.

Released under the MIT License.