From d5cf1470cf8669b05e4674aa312700aa2c9c5c98 Mon Sep 17 00:00:00 2001 From: stringsplit <77242831+nbitzz@users.noreply.github.com> Date: Sat, 27 Apr 2024 09:24:28 -0700 Subject: [PATCH] Bring back /cpt --- src/server/routes/api/v0/primaryApi.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/server/routes/api/v0/primaryApi.ts b/src/server/routes/api/v0/primaryApi.ts index 204d420..a17e56e 100644 --- a/src/server/routes/api/v0/primaryApi.ts +++ b/src/server/routes/api/v0/primaryApi.ts @@ -1,4 +1,4 @@ -import { Hono } from "hono" +import { Context, Hono } from "hono" import * as Accounts from "../../../lib/accounts.js" import * as auth from "../../../lib/auth.js" import RangeParser, { type Range } from "range-parser" @@ -20,8 +20,8 @@ export let primaryApi = new Hono<{ primaryApi.all("*", getAccount) -export default function (files: Files, apiRoot: Hono) { - primaryApi.get("/file/:fileId", async (ctx) => +function fileReader(apiRoot: Hono) { + return async (ctx: Context) => apiRoot.fetch( new Request( (new URL( @@ -30,7 +30,12 @@ export default function (files: Files, apiRoot: Hono) { ), ctx.env ) - ) +} + +export default function (files: Files, apiRoot: Hono) { + + primaryApi.get("/file/:fileId", fileReader(apiRoot)) + primaryApi.get("/cpt/:fileId/*", fileReader(apiRoot)) primaryApi.post("/upload", async (ctx) => apiRoot.fetch(