legendaryjs
Version:
LegendaryJS – The ultimate backend framework for speed, power, and simplicity.
27 lines (23 loc) • 502 B
JavaScript
const hooks = {
onRequest: [],
onError: [],
onStart: []
};
function registerHook(type, callback) {
if (hooks[type]) {
hooks[type].push(callback);
} else {
console.warn(`❌ Unknown hook type: ${type}`);
}
}
function executeHooks(type, ...args) {
if (hooks[type]) {
hooks[type].forEach(fn => {
try { fn(...args); } catch (e) { console.error(`❌ Hook error [${type}]`, e); }
});
}
}
module.exports = {
registerHook,
executeHooks
};