Architecture
Orveth is a backend framework ecosystem organized as acyclic npm packages. The framework core is @orveth/server; everything else is optional infrastructure around it.
Package layers
- Runtime —
@orveth/serverwraps Node.jshttpwith routing, middleware, and response helpers. - HTTP primitives —
@orveth/http(status, headers, response bodies) and@orveth/https(TLS material and HTTPS listeners). - Cross-cutting —
@orveth/errors,@orveth/config,@orveth/logger,@orveth/validation,@orveth/core. - Integrations —
@orveth/jwt(symmetric tokens),@orveth/prisma(health and shutdown around Prisma Client). - Convenience —
orvethmeta-package re-exports public APIs from every layer above.
Dependency rules
- No published package imports application code.
@orveth/serverdepends only on@orveth/errorsand@orveth/http.@orveth/https,@orveth/jwt, and@orveth/prismado not depend on@orveth/server—they accept minimal context shapes or Node listeners so you can use them outside the Orveth app class.- Public APIs export from package roots only; deep
src/paths are internal.
Request lifecycle
Inside @orveth/server, each inbound request follows this path:
- Node invokes the
RequestListenerfromOrveth#toRequestListener()orlisten(). - The HTTP method is parsed. Unsupported verbs receive 405 with code
ORVETH_HTTP_METHOD_NOT_ALLOWED(verbs are not coerced to GET). - The path is normalized (leading slash, query string stripped for matching).
- A
RequestContextis constructed inside a try/catch so dispatch failures still return JSON error bodies. - Registered middleware runs in order; each calls
next()to continue. - An O(1) lookup resolves
method + path. No match → 404ORVETH_HTTP_NOT_FOUND. - The route handler runs. Returning
ctx.ok()/ctx.json()is equivalent to awaiting those helpers. - If nothing commits a response, the runtime emits 500
ORVETH_NO_RESPONSE. ThrownHttpErrorvalues map to their status codes.
Routing model
- Exact match on HTTP method and path—no parameters, wildcards, or nested routers.
- Duplicate registration for the same method/path throws
ORVETH_ROUTE_DUPLICATEat startup. app.all(path, handler)registers the same handler for every supported verb.
Meta-package vs scoped installs
orveth is a thin re-export barrel. Production services should depend on @orveth/server (and optional scoped modules) so dependency graphs stay explicit and auditable.
Implementation details for each module live on the package index and individual reference pages.