@orveth/server
v0.3.0
Published
Node.js HTTP runtime with routing, middleware, and JSON helpers.
Maintainers
Readme
@orveth/server
Core HTTP runtime for the Orveth framework ecosystem: the Orveth application class with exact routing, middleware, JSON/text responses, and bounded body parsing.
Install
npm install @orveth/server @orveth/errors@orveth/errors and @orveth/http are runtime dependencies of this package.
Quick start
import { Orveth } from "@orveth/server";
const app = new Orveth();
app.get("/health", (ctx) => ctx.ok({ ok: true }));
app.post("/events", async (ctx) => {
const payload = await ctx.readJson();
return ctx.json({ received: payload }, { status: 201 });
});
await app.listen(3000);
await app.listen({ port: 3000, hostname: "127.0.0.1" });Handlers may return ctx.ok(...) / ctx.json(...) or await them—both work.
API overview
Orveth—use,route,get|post|put|patch|delete|head|options,all,listen(port, hostname?)/listen({ port, hostname? }),toRequestListenerListenOptions— options object forlistenRequestContext—json,text,ok,created,noContent,readJson,setHeader,wasResponded- Types:
Handler,RouteHandler,HandlerResult,Middleware,Next,HttpMethod DEFAULT_MAX_REQUEST_BODY_BYTES— defaultreadJsoncap (1 MiB)
Routing is exact-match on method + path (query strings ignored). Duplicate routes throw ORVETH_ROUTE_DUPLICATE at registration.
Error behavior
HttpError→ JSON with itsstatusCode- Other
OrvethError→ HTTP 500 - Unsupported HTTP verbs → 405
ORVETH_HTTP_METHOD_NOT_ALLOWED - No matching route → 404
ORVETH_HTTP_NOT_FOUND - Handler returns without a response → 500
ORVETH_NO_RESPONSE
License
MIT — see repository LICENSE.
