mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-07-08 01:31:00 +08:00
add /api/file/random
This commit is contained in:
12
routes/api/file/random.ts
Normal file
12
routes/api/file/random.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import { get_task_manager } from "../../../server.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
GET(req, _ctx) {
|
||||
const m = get_task_manager();
|
||||
const f = m.db.get_random_file();
|
||||
if (!f) return new Response("File not found.", { status: 404 });
|
||||
const u = new URL(req.url);
|
||||
return Response.redirect(`${u.origin}/api/file/${f.id}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user