Using runtime information
The runtime data and original adapter parameters can be accessed through the third runtime
parameter in any middleware or handler. For instance:
ts
import { env, type Get, type UniversalMiddleware } from "@universal-middleware/core";
const handler = (() => (request, context, runtime) => {
if (runtime.adapter === "express") {
runtime.req;
}
}) satisfies Get<[], UniversalMiddleware>;
Available properties
ts
// hover me
type Runtime = Explain<ExpressAdapter>;
ts
// hover me
type Runtime = Explain<HonoAdapter>;
ts
// hover me
type Runtime = Explain<FastifyAdapter>;
ts
// hover me
type Runtime = Explain<CloudflareWorkerAdapter>;
ts
// hover me
type Runtime = Explain<CloudflarePagesAdapter>;
ts
// hover me
type Runtime = Explain<VercelEdgeAdapter>;
ts
// hover me
type Runtime = Explain<VercelNodeAdapter>;
ts
// hover me
type Runtime = Explain<H3Adapter>;
ts
// hover me
type Runtime = Explain<ElysiaAdapter>;
ts
// hover me
type Runtime = Explain<HattipAdapter>;
NOTE
All runtime types are defined in types.ts