UNPKG

@archon-inc/sdk

Version:

Integrate easily to our government platform using this SDK. More info on https://archon.inc/sdk

14 lines (13 loc) 511 B
import getSession from "./getSession.js"; /** * Get the session object from a request object * @param req The request object to get the session from. Accepts anything that extends IncomingMessage. * @returns The session object. */ export default async function getSessionFromReq(req) { const sessionId = req.headers["x-session-id"]; if (!sessionId || typeof sessionId !== "string") { throw new Error("No session ID provided in request."); } return getSession(parseInt(sessionId)); }