Spaces:
Runtime error
Runtime error
Download apps/web/src/api/auth.ts from ClaraSu/llm-router: direct link, hf CLI and curl.
- Browser
- Download file 977 Bytes
-
https://huggingface.co/spaces/ClaraSu/llm-router/resolve/main/apps/web/src/api/auth.ts
- Command line
-
hf download hf://spaces/ClaraSu/llm-router/apps/web/src/api/auth.ts
-
curl -L -o auth.ts https://huggingface.co/spaces/ClaraSu/llm-router/resolve/main/apps/web/src/api/auth.ts
977 Bytes
| import { apiFetch } from './client' | |
| export async function login(email: string, password: string): Promise<{ token: string }> { | |
| const res = await apiFetch('/auth/login', { | |
| method: 'POST', | |
| body: JSON.stringify({ email, password }), | |
| }) | |
| if (!res.ok) { | |
| const err = await res.json() as { error?: string } | |
| throw new Error(err.error ?? 'Login failed') | |
| } | |
| return res.json() as Promise<{ token: string }> | |
| } | |
| export async function signup( | |
| email: string, | |
| password: string, | |
| tenantName?: string, | |
| country?: string, | |
| ): Promise<{ token: string }> { | |
| const res = await apiFetch('/auth/signup', { | |
| method: 'POST', | |
| body: JSON.stringify({ | |
| email, | |
| password, | |
| ...(tenantName ? { tenant_name: tenantName } : {}), | |
| ...(country ? { country } : {}), | |
| }), | |
| }) | |
| if (!res.ok) { | |
| const err = await res.json() as { error?: string } | |
| throw new Error(err.error ?? 'Signup failed') | |
| } | |
| return res.json() as Promise<{ token: string }> | |
| } | |