fix(api): 🚚 Rename "id" to "hash"

This commit is contained in:
Jesse Wierzbinski 2024-06-13 23:55:39 -10:00
parent 2ec7e512e0
commit 731fc9847c
No known key found for this signature in database

View file

@ -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();