UNPKG

@busy-hour/blaze

Version:

<h1 align='center'>🔥 Blaze</h1> <div align='center'> An event driven framework for 🔥 Hono.js </div>

32 lines (31 loc) • 905 B
// src/loader/action.ts import { eventHandler } from "../handler/index.js"; import { BlazeContext } from "../internal/context/index.js"; import { BlazeEvent } from "../internal/event-emitter/instance.js"; var BlazeServiceAction = class { serviceName; actionName; action; constructor(options) { this.serviceName = options.serviceName; this.actionName = [this.serviceName, options.actionAlias].join("."); this.action = options.action; BlazeEvent.on(this.actionName, this.actionHandler.bind(this)); } async actionHandler(...values) { const [body, params, headers, query] = values; const ctx = await BlazeContext.create({ honoCtx: null, body, headers, params, query, validator: this.action.validator ?? null, meta: this.action.meta ?? null }); return eventHandler(this.action, ctx); } }; export { BlazeServiceAction };