feat: initial NFC Attendance Hub implementation
- Multi-tenant client management with unique API keys - Semaphore SMS integration (per-client key + sender name + credit balance) - DB-based SMS queue with 3-attempt retry and exponential backoff - Failed SMS dashboard with manual retry button - Reports page with date/client filter and CSV export - Admin auth via NextAuth (email/password) - Docker Compose setup (app + PostgreSQL 16) - Prisma 5 schema with SmsQueue, SmsLog, Client, User models Tech: Next.js 14 App Router + TypeScript + Tailwind CSS + Prisma + PostgreSQL
This commit is contained in:
24
app/api/sms/failed/route.ts
Normal file
24
app/api/sms/failed/route.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { getServerSession } from 'next-auth'
|
||||
import { authOptions } from '@/lib/auth'
|
||||
import { prisma } from '@/lib/prisma'
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
const session = await getServerSession(authOptions)
|
||||
if (!session) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
||||
|
||||
const { searchParams } = new URL(req.url)
|
||||
const clientId = searchParams.get('clientId')
|
||||
|
||||
const failed = await prisma.smsQueue.findMany({
|
||||
where: {
|
||||
status: 'FAILED',
|
||||
...(clientId ? { clientId } : {}),
|
||||
},
|
||||
include: { client: { select: { name: true } } },
|
||||
orderBy: { updatedAt: 'desc' },
|
||||
take: 200,
|
||||
})
|
||||
|
||||
return NextResponse.json(failed)
|
||||
}
|
||||
Reference in New Issue
Block a user