feat: add admin dashboard and core API routes with Docker configuration

This commit is contained in:
2026-10-29 19:46:37 +01:00
parent 2fdabe1dfd
commit 4f4856d9dc
89 changed files with 1984 additions and 1034 deletions

View File

@@ -1,37 +1,52 @@
import { NextRequest, NextResponse } from 'next/server'
import prisma from '@/lib/prisma'
import { getAuthUser, USER_SAFE_SELECT } from '@/lib/auth-utils'
// PATCH /api/users/me — Update personal user profile
export async function PATCH(
request: NextRequest,
context: { params: Promise<any> }
): Promise<Response> {
// GET /api/users/me — Get current authenticated user profile
export async function GET(request: NextRequest): Promise<Response> {
try {
const userId = request.headers.get('x-user-id')
const data = await request.json()
if (!userId) {
const authUser = await getAuthUser(request)
if (!authUser) {
return NextResponse.json({ error: 'Utilisateur non identifié' }, { status: 401 })
}
const user = await prisma.user.findUnique({
where: { id: authUser.id },
select: USER_SAFE_SELECT
})
if (!user) {
return NextResponse.json({ error: 'Utilisateur introuvable' }, { status: 404 })
}
return NextResponse.json(user)
} catch (error) {
console.error('GET /api/users/me error:', error)
return NextResponse.json({ error: 'Erreur serveur' }, { status: 500 })
}
}
// PATCH /api/users/me — Update personal user profile
export async function PATCH(
request: NextRequest
): Promise<Response> {
try {
const authUser = await getAuthUser(request)
if (!authUser) {
return NextResponse.json({ error: 'Utilisateur non identifié' }, { status: 401 })
}
const data = await request.json()
const updatedUser = await prisma.user.update({
where: { id: userId },
where: { id: authUser.id },
data: {
name: data.name,
phone: data.phone,
bio: data.bio,
location: data.location,
},
select: {
id: true,
name: true,
email: true,
role: true,
phone: true,
bio: true,
location: true,
avatar: true
}
select: USER_SAFE_SELECT
})
return NextResponse.json(updatedUser)