@busy-hour/blaze
Version:
<h1 align='center'>🔥 Blaze</h1> <div align='center'> An event driven framework for 🔥 Hono.js </div>
21 lines (20 loc) • 508 B
JavaScript
// src/handler/hooks.ts
import { toArray } from "../utils/common.js";
async function beforeActionHookHandler(options) {
const hooks = toArray(options.hooks);
for (const hook of hooks) {
await hook(options.ctx);
}
}
async function afterActionHookHandler(options) {
const hooks = toArray(options.hooks);
let result = options.result;
for (const hook of hooks) {
result = await hook(options.ctx, result);
}
return result;
}
export {
afterActionHookHandler,
beforeActionHookHandler
};