/* eslint-disable @typescript-eslint/no-explicit-any */ import type { ServerWebSocket } from "bun"; import type { BunSQLiteDatabase } from "drizzle-orm/bun-sqlite"; import type { z, ZodType } from "zod"; import * as schema from "../schema"; interface RequestContext { user?: string; db: BunSQLiteDatabase; ws: ServerWebSocket; } export type Endpoint = { validate: TInputSchema; handler: ( input: z.infer, context: RequestContext, ) => Promise; }; export const createEndpoint = ( validate: TInputSchema, handler: ( input: z.infer, context: RequestContext, ) => Promise, ): Endpoint => { return { validate, handler }; }; export type Controller>> = TEndpoints; export const createController = < TEndpoints extends Record>, >( endpoints: TEndpoints, ): Controller => { return endpoints; };