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

This commit is contained in:
2026-04-30 23:05:04 +02:00
parent 81b068e5c9
commit 4e881bcbe6
5 changed files with 167 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
import { NextRequest, NextResponse } from 'next/server'
import prisma from '@/lib/prisma'
import { USER_SAFE_SELECT } from '@/lib/auth-utils'
// GET /api/businesses — List all businesses (Mock + DB)
export async function GET(request: NextRequest) {
@@ -42,7 +43,12 @@ export async function GET(request: NextRequest) {
const dbBusinesses = await prisma.business.findMany({
where,
include: { owner: true, offers: true },
include: {
owner: {
select: USER_SAFE_SELECT
},
offers: true
},
orderBy: { createdAt: 'desc' },
})
@@ -135,7 +141,11 @@ export async function POST(request: NextRequest) {
business = await prisma.business.update({
where: { id: existing.id },
data: cleanData,
include: { owner: true }
include: {
owner: {
select: USER_SAFE_SELECT
}
}
});
} else {
// When creating, we add the ownerId to the sanitized cleanData
@@ -144,7 +154,11 @@ export async function POST(request: NextRequest) {
...cleanData,
ownerId: ownerId
},
include: { owner: true }
include: {
owner: {
select: USER_SAFE_SELECT
}
}
});
// Automatic role upgrade