@busy-hour/blaze
Version:
<h1 align='center'>🔥 Blaze</h1> <div align='center'> An event driven framework for 🔥 Hono.js </div>
83 lines (82 loc) • 2.67 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var constructor_exports = {};
__export(constructor_exports, {
TrpcConstructor: () => TrpcConstructor
});
module.exports = __toCommonJS(constructor_exports);
var import_helper = require("./helper");
class TrpcConstructor {
app;
procedure;
actions;
trpcActions;
$trpcMutations;
$trpcQueries;
constructor(app, procedure) {
this.app = app;
this.procedure = procedure;
this.actions = this.app.services.map((service) => service.actions).flat(1);
this.actions = this.actions.filter((action) => action.action.trpc);
this.trpcActions = this.actions.reduce(
(prev, curr) => {
const type = curr.action.trpc;
if (!type)
return prev;
prev[type].push(curr);
return prev;
},
{ mutation: [], query: [], subscription: [] }
);
this.$trpcMutations = null;
this.$trpcQueries = null;
}
get trpcMutations() {
if (this.$trpcMutations)
return this.$trpcMutations;
this.$trpcMutations = this.trpcActions.mutation.reduce((prev, curr) => {
prev[curr.actionName] = (0, import_helper.getTrpcInput)(this.procedure, curr).mutation(
({ input }) => (0, import_helper.trpcHandler)(curr, input)
);
return prev;
}, {});
return this.$trpcMutations;
}
get trpcQueries() {
if (this.$trpcQueries)
return this.$trpcQueries;
this.$trpcQueries = this.trpcActions.query.reduce((prev, curr) => {
prev[curr.actionName] = (0, import_helper.getTrpcInput)(this.procedure, curr).query(
({ input }) => (0, import_helper.trpcHandler)(curr, input)
);
return prev;
}, {});
return this.$trpcQueries;
}
get procedures() {
return {
...this.trpcMutations,
...this.trpcQueries
};
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
TrpcConstructor
});