Download src/app/api/auth/me/route.ts from simikkk/test7: direct link, hf CLI and curl.
- Browser
- Download file 867 Bytes
-
https://huggingface.co/spaces/simikkk/test7/resolve/main/src/app/api/auth/me/route.ts
- Command line
-
hf download hf://spaces/simikkk/test7/src/app/api/auth/me/route.ts
-
curl -L -o route.ts https://huggingface.co/spaces/simikkk/test7/resolve/main/src/app/api/auth/me/route.ts
867 Bytes
| import { NextRequest, NextResponse } from 'next/server'; | |
| import { getCookieToken, getSessionUser } from '@/lib/auth'; | |
| export async function GET(request: NextRequest) { | |
| try { | |
| const token = getCookieToken(request); | |
| if (!token) { | |
| return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); | |
| } | |
| const user = await getSessionUser(token); | |
| if (!user) { | |
| return NextResponse.json({ error: 'Not authenticated' }, { status: 401 }); | |
| } | |
| return NextResponse.json({ | |
| user: { | |
| id: user.id, | |
| email: user.email, | |
| name: user.name, | |
| plan: user.plan, | |
| apiKey: user.apiKey, | |
| createdAt: user.createdAt, | |
| }, | |
| }); | |
| } catch (error) { | |
| console.error('[ME_ERROR]', error); | |
| return NextResponse.json( | |
| { error: 'Internal server error' }, | |
| { status: 500 } | |
| ); | |
| } | |
| } |