mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-03 11:45:57 -05:00
19 lines
448 B
TypeScript
19 lines
448 B
TypeScript
import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
|
interface SessionIdContext {
|
|
sessionId: string | undefined;
|
|
}
|
|
|
|
export const sessionIdAsyncLocalStorage =
|
|
new AsyncLocalStorage<SessionIdContext>();
|
|
|
|
function getSessionId(): string | undefined {
|
|
return sessionIdAsyncLocalStorage.getStore()?.sessionId;
|
|
}
|
|
|
|
declare global {
|
|
var __getServerSessionId: (() => string | undefined) | undefined;
|
|
}
|
|
|
|
globalThis.__getServerSessionId = getSessionId;
|