mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
12 lines
426 B
TypeScript
12 lines
426 B
TypeScript
import { AsyncLocalStorage } from "node:async_hooks";
|
|
import type { IncomingMessage } from "node:http";
|
|
|
|
/**
|
|
* Async local storage for the current HTTP request context. This allows
|
|
* downstream code (e.g. Sequelize hooks) to check whether the originating
|
|
* request is still alive without explicitly threading `ctx` through every call.
|
|
*/
|
|
export const requestContext = new AsyncLocalStorage<{
|
|
req: IncomingMessage;
|
|
}>();
|