Files
Nemo b273f1a573 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
2026-03-12 08:49:13 +00:00

26 lines
998 B
TypeScript

import { NextRequest, NextResponse } from 'next/server'
import { getServerSession } from 'next-auth'
import { authOptions } from '@/lib/auth'
import { prisma } from '@/lib/prisma'
export async function POST(req: NextRequest, { params }: { params: { id: string } }) {
const session = await getServerSession(authOptions)
if (!session) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
const queue = await prisma.smsQueue.findUnique({ where: { id: params.id } })
if (!queue) return NextResponse.json({ error: 'Not found' }, { status: 404 })
await prisma.smsQueue.update({
where: { id: params.id },
data: { status: 'PENDING', attempts: 0, lastError: null, scheduledAt: new Date() },
})
// Trigger processing
fetch(`${process.env.NEXTAUTH_URL}/api/queue/process`, {
method: 'POST',
headers: { 'x-internal-key': process.env.INTERNAL_API_KEY || '' },
}).catch(() => {})
return NextResponse.json({ success: true, message: 'Queued for retry' })
}