feat: 完善鉴权

This commit is contained in:
2026-05-22 23:10:40 +08:00
parent 3857f77f8b
commit c48d57df14
14 changed files with 118 additions and 117 deletions
+16
View File
@@ -0,0 +1,16 @@
// 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;
}
}