feat: 完善鉴权
This commit is contained in:
Vendored
+16
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user