Download server/_core/context.ts from zuocong12/README: direct link, hf CLI and curl.
- Browser
- Download file 605 Bytes
-
https://huggingface.co/spaces/zuocong12/README/resolve/main/server/_core/context.ts
- Command line
-
hf download hf://spaces/zuocong12/README/server/_core/context.ts
-
curl -L -o context.ts https://huggingface.co/spaces/zuocong12/README/resolve/main/server/_core/context.ts
605 Bytes
| import type { CreateExpressContextOptions } from "@trpc/server/adapters/express"; | |
| import type { User } from "../../drizzle/schema"; | |
| export type TrpcContext = { | |
| req: CreateExpressContextOptions["req"]; | |
| res: CreateExpressContextOptions["res"]; | |
| user: User | null; | |
| }; | |
| export async function createContext( | |
| opts: CreateExpressContextOptions | |
| ): Promise<TrpcContext> { | |
| // 本地模式: 不进行认证,所有用户均可访问 | |
| // 如需要简单认证,可以后续添加基于密码的本地认证 | |
| const user: User | null = null; | |
| return { | |
| req: opts.req, | |
| res: opts.res, | |
| user, | |
| }; | |
| } | |