feat: implement business and user CRUD API endpoints with authentication utilities and update feature documentation
All checks were successful
Build and Push App / build (push) Successful in 5m46s
All checks were successful
Build and Push App / build (push) Successful in 5m46s
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import prisma from '@/lib/prisma'
|
||||
import { USER_SAFE_SELECT } from '@/lib/auth-utils'
|
||||
|
||||
type Params = { params: Promise<{ id: string }> }
|
||||
|
||||
@@ -17,7 +18,12 @@ export async function GET(
|
||||
{ slug: id }
|
||||
]
|
||||
},
|
||||
include: { owner: true, offers: true },
|
||||
include: {
|
||||
owner: {
|
||||
select: USER_SAFE_SELECT
|
||||
},
|
||||
offers: true
|
||||
},
|
||||
})
|
||||
if (!business) return NextResponse.json({ error: 'Non trouvé' }, { status: 404 })
|
||||
return NextResponse.json(business)
|
||||
@@ -38,7 +44,12 @@ export async function PATCH(
|
||||
const business = await prisma.business.update({
|
||||
where: { id },
|
||||
data: body,
|
||||
include: { owner: true, offers: true },
|
||||
include: {
|
||||
owner: {
|
||||
select: USER_SAFE_SELECT
|
||||
},
|
||||
offers: true
|
||||
},
|
||||
})
|
||||
return NextResponse.json(business)
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user