open-api-aurum-connector-fingo
Version:
Module to connect to the OPEN API Aurum Core
44 lines (36 loc) • 945 B
JavaScript
const { AsyncLocalStorage } = require("async_hooks");
const asyncLocalStorage = new AsyncLocalStorage();
const TRANSACTION_ID = "transactionId";
const getTransactionContext = () => {
const store = asyncLocalStorage.getStore();
if (store) {
return store.get(TRANSACTION_ID);
}
return null;
};
const getTransactionContextId = () => {
const store = asyncLocalStorage.getStore();
if (store) {
return store.get(TRANSACTION_ID);
}
return null;
};
const setUserTransactionContext = (user) => {
const store = asyncLocalStorage.getStore();
if (store) {
store.set("user", user);
}
};
const getUserTransactionContext = () => {
const store = asyncLocalStorage.getStore();
if (store) {
return store.get("user");
}
return null;
};
module.exports = {
getTransactionContext,
getTransactionContextId,
setUserTransactionContext,
getUserTransactionContext,
};