mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(api): 🚚 Refactor authentication middleware and implement some OpenAPI routes
This commit is contained in:
parent
edf5edca9f
commit
1ab1c68d36
66 changed files with 383 additions and 279 deletions
20
types/api.ts
20
types/api.ts
|
|
@ -11,8 +11,10 @@ import type {
|
|||
Unfollow,
|
||||
User,
|
||||
} from "@versia/federation/types";
|
||||
import type { z } from "zod";
|
||||
import { z } from "zod";
|
||||
import type { Application } from "~/classes/functions/application";
|
||||
import type { RolePermissions } from "~/drizzle/schema";
|
||||
import type { User as DatabaseUser } from "~/packages/database-interface/user";
|
||||
|
||||
export type HttpVerb = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS";
|
||||
export interface ApiRouteMetadata {
|
||||
|
|
@ -43,13 +45,27 @@ export interface ApiRouteMetadata {
|
|||
};
|
||||
}
|
||||
|
||||
export const ErrorSchema = z.object({
|
||||
error: z.string(),
|
||||
});
|
||||
|
||||
export type HonoEnv = {
|
||||
Variables: {
|
||||
auth: {
|
||||
user: DatabaseUser | null;
|
||||
token: string | null;
|
||||
application: Application | null;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export interface ApiRouteExports {
|
||||
meta: ApiRouteMetadata;
|
||||
schemas?: {
|
||||
query?: z.AnyZodObject;
|
||||
body?: z.AnyZodObject;
|
||||
};
|
||||
default: (app: OpenAPIHono) => RouterRoute;
|
||||
default: (app: OpenAPIHono<HonoEnv>) => RouterRoute;
|
||||
}
|
||||
|
||||
export type KnownEntity =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue