UNPKG

@archon-inc/sdk

Version:

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

20 lines (19 loc) 794 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = getSessionFromReq; const getSession_js_1 = __importDefault(require("./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. */ 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 (0, getSession_js_1.default)(parseInt(sessionId)); }