Skip to main content

Function: createSessionMiddleware()

createSessionMiddleware(mgr): RequestHandler

Defined in: service-core/src/http/session/sessionMiddleware.ts:31

Builds a global, framework-agnostic session middleware backed by the given SessionManager. Lazily loads-or-creates req.session and persists any mutations back to the store once the response finishes. Cheap for requests that never touch sessions: no store round-trip unless a valid session cookie was actually sent, and no Set-Cookie/store write for sessions that end up empty.

NOTE: both HTTP adapters currently back res.setHeader() with a single-value map, so only one Set-Cookie header can be represented per response. This is the first feature to ever set Set-Cookie — safe today, but a second cookie-writing feature would silently clobber this one.

Parameters

mgr

SessionManager

Returns

RequestHandler