mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor: ♻️ Use a typed wrapper for all API endpoints
This commit is contained in:
parent
af931b8ade
commit
1a8e063f87
97 changed files with 479 additions and 382 deletions
10
utils/api.ts
10
utils/api.ts
|
|
@ -1,5 +1,5 @@
|
|||
import { errorResponse } from "@/response";
|
||||
import type { Context } from "@hono/hono";
|
||||
import type { Context, Hono } from "@hono/hono";
|
||||
import { createMiddleware } from "@hono/hono/factory";
|
||||
import type { StatusCode } from "@hono/hono/utils/http-status";
|
||||
import { validator } from "@hono/hono/validator";
|
||||
|
|
@ -44,6 +44,14 @@ export const applyConfig = (routeMeta: ApiRouteMetadata) => {
|
|||
return newMeta;
|
||||
};
|
||||
|
||||
export const apiRoute = (
|
||||
fn: (
|
||||
app: Hono /* <{
|
||||
Bindings: {};
|
||||
}> */,
|
||||
) => void,
|
||||
) => fn;
|
||||
|
||||
export const idValidator = createRegExp(
|
||||
anyOf(digit, charIn("ABCDEF")).times(8),
|
||||
exactly("-"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue