mirror of
https://github.com/versia-pub/server.git
synced 2026-01-26 12:16:01 +01:00
fix(api): 🚚 Rename "id" to "hash"
This commit is contained in:
parent
2ec7e512e0
commit
731fc9847c
|
|
@ -6,7 +6,7 @@ import { z } from "zod";
|
||||||
|
|
||||||
export const meta = applyConfig({
|
export const meta = applyConfig({
|
||||||
allowedMethods: ["GET"],
|
allowedMethods: ["GET"],
|
||||||
route: "/media/:id/:name",
|
route: "/media/:hash/:name",
|
||||||
ratelimits: {
|
ratelimits: {
|
||||||
max: 100,
|
max: 100,
|
||||||
duration: 60,
|
duration: 60,
|
||||||
|
|
@ -18,7 +18,7 @@ export const meta = applyConfig({
|
||||||
|
|
||||||
export const schemas = {
|
export const schemas = {
|
||||||
param: z.object({
|
param: z.object({
|
||||||
id: z.string(),
|
hash: z.string(),
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
}),
|
}),
|
||||||
header: z.object({
|
header: z.object({
|
||||||
|
|
@ -33,7 +33,7 @@ export default (app: Hono) =>
|
||||||
zValidator("param", schemas.param, handleZodError),
|
zValidator("param", schemas.param, handleZodError),
|
||||||
zValidator("header", schemas.header, handleZodError),
|
zValidator("header", schemas.header, handleZodError),
|
||||||
async (context) => {
|
async (context) => {
|
||||||
const { id, name } = context.req.valid("param");
|
const { hash, name } = context.req.valid("param");
|
||||||
const { range } = context.req.valid("header");
|
const { range } = context.req.valid("header");
|
||||||
|
|
||||||
// parse `Range` header
|
// parse `Range` header
|
||||||
|
|
@ -46,7 +46,7 @@ export default (app: Hono) =>
|
||||||
.map(Number); // [0, 100]
|
.map(Number); // [0, 100]
|
||||||
|
|
||||||
// Serve file from filesystem
|
// Serve file from filesystem
|
||||||
const file = Bun.file(`./uploads/${id}/${name}`);
|
const file = Bun.file(`./uploads/${hash}/${name}`);
|
||||||
|
|
||||||
const buffer = await file.arrayBuffer();
|
const buffer = await file.arrayBuffer();
|
||||||
|
|
||||||
Loading…
Reference in a new issue