17 lines
507 B
TypeScript
17 lines
507 B
TypeScript
// server/types.d.ts - H3EventContext 扩展,供所有 server handler 使用
|
|
import type { auth } from "~~/server/utils/auth";
|
|
|
|
type BetterAuthSession = NonNullable<
|
|
Awaited<ReturnType<typeof auth.api.getSession>>
|
|
>;
|
|
|
|
declare module "h3" {
|
|
interface H3EventContext {
|
|
/**
|
|
* Better Auth session,由 api-auth middleware 在非公开路由上设置。
|
|
* 公开路由(publicApiRoutes)不会被赋值,业务接口可安全断言为非空。
|
|
*/
|
|
auth?: BetterAuthSession;
|
|
}
|
|
}
|