ThunderIDExpressClient
ThunderIDExpressClient is the Express-aware client class exported by @thunderid/express. It extends ThunderIDNodeClient and adds Express-specific request and configuration access.
Import
const {ThunderIDExpressClient} = require('@thunderid/express');
Overview
In most applications, you do not instantiate this class directly. The thunderID() middleware creates and initializes it for you, then attaches it to req.thunderIDAuth and res.thunderIDAuth.
Express-Specific Members
expressConfig
Returns the initialized ExpressClientConfig value or undefined if the client has not been initialized yet.
| Member | Type | Description |
|---|---|---|
expressConfig | ExpressClientConfig | undefined | The Express SDK configuration used to initialize the client |
getUserFromRequest(req)
Reads the session ID from req.cookies[SESSION_COOKIE_NAME] and returns the current user for that session.
getUserFromRequest(req: express.Request): Promise<User | undefined>
app.get('/me', async (req, res) => {
const user = await req.thunderIDAuth.getUserFromRequest(req);
res.json(user);
});
Inherited Behavior
Because ThunderIDExpressClient extends ThunderIDNodeClient, inherited Node client methods are also available. This Express SDK section does not provide a full reference for the inherited Node surface.
Notes
getUserFromRequest(req)depends onreq.cookies, so mountcookie-parserbefore routes that use itsignIn()andsignOut()are also overridden internally to integrate with Express request and response handling, but this page focuses on the public Express-specific additions