Current User Context
Attach the authenticated user already present on your request.
getCurrentUser is optional. ServerDevTools does not identify users through Passport, JWT, or another authentication framework. Supply a function only when your application already exposes the authenticated user on the incoming request.
import type { IncomingMessage } from "node:http";
const devtools = new ServerDevTools({
auth: { username: "dev", password: "local-password" },
getCurrentUser: (req) => (req as IncomingMessage & {
user?: { id: string; role?: string };
}).user,
});The returned object is saved with the trace when the response finishes. Treat it as sensitive application data and enable encryption when appropriate.
Last updated on