authenticated
@rotorsoft/act-root / act-http/src/hono / authenticated
Function: authenticated()
authenticated(
extractor):MiddlewareHandler<{Variables:ActMiddlewareVariables; }>
Defined in: libs/act-http/src/hono/index.ts:159
Build a Hono middleware that runs an ActorExtractor once
per call and stashes the resolved Actor under
c.set("actor", ...) so downstream routes can read it via
c.get("actor"). The generator at hono uses this
internally; it's also exported so hosts that want to compose
their own route chain (logging, tracing, custom auth flavors)
can wire it directly:
import { Hono } from "hono";
import { authenticated, type ActMiddlewareVariables } from "@rotorsoft/act-http/hono";
const api = new Hono<{ Variables: ActMiddlewareVariables }>();
api.use("*", authenticated((c) => resolveUserFromJwt(c)));
api.get("/me", (c) => c.json(c.get("actor"))); // typed
Errors thrown by the extractor surface as 401 Unauthorized with
the shared ApiError envelope.
Parametersโ
extractorโ
ActorExtractor
Returnsโ
MiddlewareHandler<{ Variables: ActMiddlewareVariables; }>