File
Blob: src/worker/hono.ts
| 1 | import type { Context } from "hono"; |
| 2 | |
| 3 | import type { Auth } from "@/worker/auth"; |
| 4 | import type { Database } from "@/worker/db"; |
| 5 | import type { LogLevel, Logger } from "@/worker/logger"; |
| 6 | |
| 7 | // `Auth["$Infer"]["Session"]` is Better Auth's plugin-inferred session |
| 8 | // shape — carries the admin plugin's `role`, `banned`, `banExpires`, |
| 9 | // `banReason` and any future `additionalFields` (e.g. |
| 10 | // `preferredUsername`) through to every handler that pulls the session |
| 11 | // off the request context. Manually-written shapes drift as the plugin |
| 12 | // tuple changes. |
| 13 | export type AppSession = Auth["$Infer"]["Session"]; |
| 14 | |
| 15 | export interface AppBindings { |
| 16 | Bindings: Env; |
| 17 | Variables: { |
| 18 | auth: Auth; |
| 19 | baseURL: string; |
| 20 | issuer: string; |
| 21 | db: Database; |
| 22 | log: Logger; |
| 23 | logLevel: LogLevel; |
| 24 | session?: AppSession | null; |
| 25 | }; |
| 26 | } |
| 27 | |
| 28 | export type AppContext = Context<AppBindings>; |