@botonic/core
Version:
Runtime and APIs for Botonic bots: actions, context, messaging, and integration hooks used by the **current** framework line.
23 lines • 888 B
JavaScript
import { __awaiter } from "tslib";
import { PluginMode } from '../server';
export function runPlugins(_a) {
return __awaiter(this, arguments, void 0, function* ({ botonicContext, mode, response = { status: 200, response: 'OK' }, }) {
const plugins = botonicContext.plugins;
for (const key in plugins) {
const plugin = plugins[key];
try {
if (mode === PluginMode.PRE && typeof plugin.pre === 'function') {
yield plugin.pre(botonicContext);
}
if (mode === PluginMode.POST && typeof plugin.post === 'function') {
botonicContext.response = response;
yield plugin.post(botonicContext);
}
}
catch (e) {
console.log(e);
}
}
});
}
//# sourceMappingURL=index.js.map