- Add @project-e/db package with Drizzle schema and migrations - Replace PocketBase client with PostgreSQL-based database client - Migrate auth from custom to NextAuth.js - Add Docker Compose with PostgreSQL container - Update worker to use new database client - Remove PocketBase-specific files and migrations - Add drizzle config and initial migration
22 lines
562 B
TypeScript
22 lines
562 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { getAuthUser } from '@/lib/auth';
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const user = await getAuthUser(request);
|
|
if (!user) {
|
|
return NextResponse.json(
|
|
{ error: { code: 'UNAUTHORIZED', message: 'Not authenticated' } },
|
|
{ status: 401 }
|
|
);
|
|
}
|
|
|
|
return NextResponse.json({ user });
|
|
} catch {
|
|
return NextResponse.json(
|
|
{ error: { code: 'AUTH_ERROR', message: 'Invalid or expired token' } },
|
|
{ status: 401 }
|
|
);
|
|
}
|
|
}
|