first commit

This commit is contained in:
2026-08-05 19:40:55 +03:00
commit 3952b61edf
55 changed files with 10964 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
import { NextRequest, NextResponse } from 'next/server'
import { prisma } from '@/lib/db'
import { ContactSchema } from '@/lib/validations'
export async function POST(req: NextRequest) {
try {
const body = await req.json()
const parsed = ContactSchema.safeParse(body)
if (!parsed.success) {
return NextResponse.json({ error: parsed.error.flatten() }, { status: 400 })
}
const message = await prisma.contactMessage.create({
data: parsed.data,
})
return NextResponse.json({ data: message }, { status: 201 })
} catch (error) {
console.error('Contact form error:', error)
return NextResponse.json({ error: 'Server error' }, { status: 500 })
}
}
export async function GET() {
try {
const messages = await prisma.contactMessage.findMany({
where: { deletedAt: null },
orderBy: { createdAt: 'desc' },
})
return NextResponse.json({ data: messages })
} catch {
return NextResponse.json({ error: 'Server error' }, { status: 500 })
}
}