Introduction
The NJ Rajat Mahotsav API is built on Next.js 15 App Router with server-side route handlers. The API provides endpoints for event registration management, admin operations, file uploads, and secure file downloads.Architecture
Technology Stack
- Framework: Next.js 15 with App Router
- Database: Supabase (PostgreSQL)
- Storage: Cloudflare R2 (S3-compatible)
- CDN: Cloudflare CDN
- Authentication: Supabase Auth
API Structure
All API routes follow Next.js 15 App Router conventions and are located in theapp/api/ directory:
Authentication
Public Endpoints
- Registration submission (client-side Supabase)
- File download proxy (validated domains only)
Admin-Only Endpoints
Admin endpoints require authenticated sessions with@nj.sgadi.us domain email addresses.
Authentication Flow:
- User authenticates via Supabase Auth
- Server verifies session using
createClient()from@/utils/supabase/server - Email domain is validated using
isAdminDomainUser()from@/lib/admin-auth - Returns 401 (Unauthorized) if not signed in
- Returns 403 (Forbidden) if not admin domain
Response Formats
Success Response
Error Response
Rate Limiting
Rate limiting is handled at the infrastructure level by Vercel and Cloudflare. No explicit rate limits are enforced in application code.
CORS Policy
All API endpoints follow Next.js default CORS policy. Admin endpoints include cache control headers:Error Codes
| Status Code | Description |
|---|---|
| 200 | Success |
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Authentication required |
| 403 | Forbidden - Insufficient permissions |
| 405 | Method Not Allowed |
| 413 | Payload Too Large - File size exceeds limit |
| 500 | Internal Server Error |
Security Best Practices
Domain Allowlisting
File download endpoints use strict domain allowlisting:Input Sanitization
All user inputs are sanitized to prevent:- Path traversal attacks
- SQL injection (via Supabase parameterized queries)
- XSS attacks
File Upload Security
- Pre-signed URLs with 10-minute expiration
- Content-Type validation
- File size limits (10MB for downloads)
- Unique file paths using submission IDs
Pagination
Admin registration endpoints use keyset pagination (cursor-based) for efficient data retrieval:Number of records per page. Allowed values: 25, 50, 100
ID of the last record from previous page
Pagination direction:
next or prevDate Formats
All dates use ISO 8601 format:YYYY-MM-DD
Registration Date Range:
- Start:
2026-07-23 - End:
2026-08-08
Related Resources
Registration API
Event registration endpoints and schemas
Admin API
Administrative endpoints for data management
File Upload API
Secure file upload with pre-signed URLs
