mirror of
https://github.com/khairul169/home-lab.git
synced 2025-04-29 00:59:36 +07:00
24 lines
804 B
TypeScript
24 lines
804 B
TypeScript
import { zValidator } from "@hono/zod-validator";
|
|
import { Hono } from "hono";
|
|
import { getFilesSchema, ytdlSchema } from "./schema";
|
|
import { getFiles } from "./get";
|
|
import { download } from "./download";
|
|
import { getYtdl, ytdl } from "./ytdl";
|
|
import cache from "../../middlewares/cache";
|
|
import { getId3Tags, getId3Image } from "./id3Tags";
|
|
import { deleteFile } from "./delete";
|
|
|
|
const cacheFile = cache({ ttl: 86400 });
|
|
|
|
const route = new Hono()
|
|
.get("/", zValidator("query", getFilesSchema), getFiles)
|
|
.post("/upload")
|
|
.post("/ytdl", zValidator("json", ytdlSchema), ytdl)
|
|
.get("/ytdl/:id", getYtdl)
|
|
.get("/download/*", cacheFile, download)
|
|
.get("/id3-tags/*", cacheFile, getId3Tags)
|
|
.get("/id3-img/*", cacheFile, getId3Image)
|
|
.delete("/delete", deleteFile);
|
|
|
|
export default route;
|