save avant prochaine modif

This commit is contained in:
2026-04-08 14:46:10 +02:00
parent bb10407e66
commit d88ba7c53c
1747 changed files with 194075 additions and 2433 deletions

28
app/api/users/route.ts Normal file
View File

@@ -0,0 +1,28 @@
import { NextRequest, NextResponse } from 'next/server'
import prisma from '../../../lib/prisma'
// GET /api/users
export async function GET() {
try {
const users = await prisma.user.findMany({
include: { businesses: true },
orderBy: { createdAt: 'desc' },
})
return NextResponse.json(users)
} catch (error) {
console.error('GET /api/users error:', error)
return NextResponse.json({ error: 'Erreur serveur' }, { status: 500 })
}
}
// POST /api/users
export async function POST(request: NextRequest) {
try {
const body = await request.json()
const user = await prisma.user.create({ data: body })
return NextResponse.json(user, { status: 201 })
} catch (error) {
console.error('POST /api/users error:', error)
return NextResponse.json({ error: 'Erreur lors de la création' }, { status: 500 })
}
}