Skip to content

Commit c016039

Browse files
committed
feat: Add log API endpoint and enhance error logging in task handler
1 parent b534cad commit c016039

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

fresh.gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import * as $api_gallery_gid_ from "./routes/api/gallery/[gid].ts";
2222
import * as $api_gallery_list from "./routes/api/gallery/list.ts";
2323
import * as $api_gallery_meta_gids_ from "./routes/api/gallery/meta/[gids].ts";
2424
import * as $api_health_check from "./routes/api/health_check.ts";
25+
import * as $api_log from "./routes/api/log.ts";
2526
import * as $api_shared_token from "./routes/api/shared_token.ts";
2627
import * as $api_shared_token_list from "./routes/api/shared_token/list.ts";
2728
import * as $api_status from "./routes/api/status.ts";
@@ -72,6 +73,7 @@ const manifest = {
7273
"./routes/api/gallery/list.ts": $api_gallery_list,
7374
"./routes/api/gallery/meta/[gids].ts": $api_gallery_meta_gids_,
7475
"./routes/api/health_check.ts": $api_health_check,
76+
"./routes/api/log.ts": $api_log,
7577
"./routes/api/shared_token.ts": $api_shared_token,
7678
"./routes/api/shared_token/list.ts": $api_shared_token_list,
7779
"./routes/api/status.ts": $api_status,

routes/api/task.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ export const handler: Handlers = {
148148
}
149149
return return_data(task, 201);
150150
} catch (e) {
151-
return return_error(500, e.message);
151+
logger.error("Failed to add download task:", e);
152+
return return_error(500, "Internal Server Error");
152153
}
153154
} else if (typ == "export_zip") {
154155
const gid = await parse_big_int(form.get("gid"), null);
@@ -168,15 +169,17 @@ export const handler: Handlers = {
168169
const task = await t.add_export_zip_task(gid, dcfg);
169170
return return_data(task, 201);
170171
} catch (e) {
171-
return return_error(500, e.message);
172+
logger.error("Failed to add export zip task:", e);
173+
return return_error(500, "Internal Server Error");
172174
}
173175
} else if (typ == "update_meili_search_data") {
174176
const gid = await parse_big_int(form.get("gid"), 0);
175177
try {
176178
const task = await t.add_update_meili_search_data_task(gid);
177179
return return_data(task, 201);
178180
} catch (e) {
179-
return return_error(500, e.message);
181+
logger.error("Failed to add update meili search data task:", e);
182+
return return_error(500, "Internal Server Error");
180183
}
181184
} else if (typ == "import") {
182185
const gid = await parse_big_int(form.get("gid"), null);
@@ -207,7 +210,8 @@ export const handler: Handlers = {
207210
}
208211
return return_data(task, 201);
209212
} catch (e) {
210-
return return_error(500, e.message);
213+
logger.error("Failed to add import task:", e);
214+
return return_error(500, "Internal Server Error");
211215
}
212216
} else if (typ == "update_tag_translation") {
213217
const cfg = await get_string(form.get("cfg"));
@@ -229,7 +233,8 @@ export const handler: Handlers = {
229233
}
230234
return return_data(task, 201);
231235
} catch (e) {
232-
return return_error(500, e.message);
236+
logger.error("Failed to add update tag translation task:", e);
237+
return return_error(500, "Internal Server Error");
233238
}
234239
} else {
235240
return return_error(5, "unknown type");

0 commit comments

Comments
 (0)