mirror of
https://github.com/wekan/wekan.git
synced 2026-11-07 11:02:33 -05:00
18 lines
597 B
JavaScript
18 lines
597 B
JavaScript
// Preserve the current HTTP request across awaited work so every Problems
|
|
// logger can recover the same actor/address/location context without each route
|
|
// having to forward `req` through every helper layer.
|
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
import { WebApp } from 'meteor/webapp';
|
|
|
|
const requestStorage = new AsyncLocalStorage();
|
|
|
|
WebApp.handlers.use(function problemReportRequestContext(req, res, next) {
|
|
requestStorage.run(req, next);
|
|
});
|
|
|
|
export function currentReportRequest() {
|
|
return requestStorage.getStore() || null;
|
|
}
|
|
|
|
export default { currentReportRequest };
|