Skip to content
File

Blob: src/worker/hono.ts

typescript29 lines
1import type { Context } from "hono";
2 
3import type { Auth } from "@/worker/auth";
4import type { Database } from "@/worker/db";
5import 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.
13export type AppSession = Auth["$Infer"]["Session"];
14 
15export 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 
28export type AppContext = Context<AppBindings>;