Skip to content

Commit 3e1b2fa

Browse files
authored
Merge pull request #14 from devforth/feature/AdminForth/1611/display-the-appropriate-respon
fix: improve job status endpoint error handling and update adminforth…
2 parents 4dd5185 + 972269c commit 3e1b2fa

3 files changed

Lines changed: 210 additions & 23 deletions

File tree

index.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,16 +1017,37 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
10171017
server.endpoint({
10181018
method: 'POST',
10191019
path: `/plugin/${this.pluginInstanceId}/get-job-status`,
1020-
handler: async ({ body, adminUser, headers }) => {
1020+
handler: async ({ body, adminUser, headers, response }) => {
10211021
const jobId = body.jobId;
10221022
if (!jobId) {
1023-
return { error: "Can't find job id" };
1023+
response.setStatus(400);
1024+
1025+
return {
1026+
ok: false,
1027+
error: "Can't find job id",
1028+
};
10241029
}
10251030
const job = jobs.get(jobId);
10261031
if (!job) {
1027-
return { error: "Job not found" };
1032+
response.setStatus(404);
1033+
1034+
return {
1035+
ok: false,
1036+
error: "Job not found",
1037+
};
10281038
}
1029-
return { ok: true, job };
1039+
if (job.status === 'failed') {
1040+
response.setStatus(500);
1041+
1042+
return {
1043+
ok: false,
1044+
error: job.error
1045+
};
1046+
}
1047+
return {
1048+
ok: true,
1049+
job,
1050+
};
10301051
}
10311052
});
10321053

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"description": "Bulk AI workflow plugin for AdminForth for batch field generation and image processing",
2626
"devDependencies": {
2727
"@types/node": "latest",
28-
"adminforth": "^2.42.0",
28+
"adminforth": "^2.60.2",
2929
"semantic-release": "^24.2.1",
3030
"semantic-release-slack-bot": "^4.0.2",
3131
"typescript": "^5.7.3"

0 commit comments

Comments
 (0)