From 731fc9847c3c33a6a86500c9f64cb676ebefb4cf Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Thu, 13 Jun 2024 23:55:39 -1000 Subject: [PATCH] fix(api): :truck: Rename "id" to "hash" --- server/api/media/{:id => :hash}/:name/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename server/api/media/{:id => :hash}/:name/index.ts (90%) diff --git a/server/api/media/:id/:name/index.ts b/server/api/media/:hash/:name/index.ts similarity index 90% rename from server/api/media/:id/:name/index.ts rename to server/api/media/:hash/:name/index.ts index 3bfe4e50..efa36b81 100644 --- a/server/api/media/:id/:name/index.ts +++ b/server/api/media/:hash/:name/index.ts @@ -6,7 +6,7 @@ import { z } from "zod"; export const meta = applyConfig({ allowedMethods: ["GET"], - route: "/media/:id/:name", + route: "/media/:hash/:name", ratelimits: { max: 100, duration: 60, @@ -18,7 +18,7 @@ export const meta = applyConfig({ export const schemas = { param: z.object({ - id: z.string(), + hash: z.string(), name: z.string(), }), header: z.object({ @@ -33,7 +33,7 @@ export default (app: Hono) => zValidator("param", schemas.param, handleZodError), zValidator("header", schemas.header, handleZodError), async (context) => { - const { id, name } = context.req.valid("param"); + const { hash, name } = context.req.valid("param"); const { range } = context.req.valid("header"); // parse `Range` header @@ -46,7 +46,7 @@ export default (app: Hono) => .map(Number); // [0, 100] // Serve file from filesystem - const file = Bun.file(`./uploads/${id}/${name}`); + const file = Bun.file(`./uploads/${hash}/${name}`); const buffer = await file.arrayBuffer();