actionhero
Version:
actionhero.js is a multi-transport API Server with integrated cluster capabilities and delayed tasks
40 lines (39 loc) • 1.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RunAction = void 0;
const index_1 = require("./../index");
class RunAction extends index_1.Task {
constructor() {
super();
this.name = "runAction";
this.description = "I will run an action and return the connection object";
this.frequency = 0;
this.queue = "default";
this.middleware = [];
}
async run(params) {
if (!params) {
params = {};
}
const connection = new index_1.Connection({
type: "task",
remotePort: "0",
remoteIP: "0",
rawConnection: {},
});
connection.params = params;
const actionProcessor = new index_1.ActionProcessor(connection);
const { response } = await actionProcessor.processAction();
if (response.error) {
index_1.log("task error: " + response.error, "error", {
params: JSON.stringify(params),
});
}
else {
index_1.log("[ action @ task ]", "debug", { params: JSON.stringify(params) });
}
connection.destroy();
return response;
}
}
exports.RunAction = RunAction;