refactor: shorter check

This commit is contained in:
Barış Soner Uşaklı
2026-02-21 18:56:53 -05:00
parent 63c9a6e03c
commit a70a62ccf9

View File

@@ -181,15 +181,13 @@ async function fireActionHook(hook, hookList, params) {
return;
}
for (const hookObj of hookList) {
if (!isHookValid(hook, hookObj)) {
continue;
}
try {
// eslint-disable-next-line
await hookObj.method(params);
} catch (err) {
winston.error(`[plugins] Error in hook ${hookObj.id}@${hookObj.hook} \n${err.stack}`);
if (isHookValid(hook, hookObj)) {
try {
// eslint-disable-next-line
await hookObj.method(params);
} catch (err) {
winston.error(`[plugins] Error in hook ${hookObj.id}@${hookObj.hook} \n${err.stack}`);
}
}
}
}
@@ -255,16 +253,14 @@ async function fireResponseHook(hook, hookList, params) {
return;
}
for (const hookObj of hookList) {
if (!isHookValid(hook, hookObj)) {
continue;
}
if (isHookValid(hook, hookObj)) {
// Skip remaining hooks if headers have been sent
if (params.res.headersSent) {
return;
}
// Skip remaining hooks if headers have been sent
if (params.res.headersSent) {
return;
// eslint-disable-next-line no-await-in-loop
await hookObj.method(params);
}
// eslint-disable-next-line no-await-in-loop
await hookObj.method(params);
}
}