refactor: ♻️ Use a typed wrapper for all API endpoints

This commit is contained in:
Jesse Wierzbinski 2024-08-19 20:06:38 +02:00 committed by April John
parent af931b8ade
commit 1a8e063f87
97 changed files with 479 additions and 382 deletions

View file

@ -1,6 +1,5 @@
import { applyConfig, handleZodError } from "@/api";
import { apiRoute, applyConfig, handleZodError } from "@/api";
import { errorResponse, response } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { z } from "zod";
@ -26,7 +25,7 @@ export const schemas = {
}),
};
export default (app: Hono) =>
export default apiRoute((app) =>
app.on(
meta.allowedMethods,
meta.route,
@ -61,4 +60,5 @@ export default (app: Hono) =>
"Content-Range": `bytes ${start}-${end}/${file.size}`,
});
},
);
),
);