Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Download server/_core/context.ts from emresar/aimusic-attribution: direct link, hf CLI and curl.
- Browser
- Download file 658 Bytes
-
https://huggingface.co/spaces/emresar/aimusic-attribution/resolve/main/server/_core/context.ts
- Command line
-
hf download hf://spaces/emresar/aimusic-attribution/server/_core/context.ts
-
curl -L -o context.ts https://huggingface.co/spaces/emresar/aimusic-attribution/resolve/main/server/_core/context.ts
658 Bytes
| import type { CreateExpressContextOptions } from "@trpc/server/adapters/express"; | |
| import type { User } from "../../drizzle/schema"; | |
| import { sdk } from "./sdk"; | |
| export type TrpcContext = { | |
| req: CreateExpressContextOptions["req"]; | |
| res: CreateExpressContextOptions["res"]; | |
| user: User | null; | |
| }; | |
| export async function createContext( | |
| opts: CreateExpressContextOptions | |
| ): Promise<TrpcContext> { | |
| let user: User | null = null; | |
| try { | |
| user = await sdk.authenticateRequest(opts.req); | |
| } catch (error) { | |
| // Authentication is optional for public procedures. | |
| user = null; | |
| } | |
| return { | |
| req: opts.req, | |
| res: opts.res, | |
| user, | |
| }; | |
| } | |