Utility APIs
Supporting endpoints for chat, email reminders, file proxying, and year-end reviews.
GET/POST /api/chat
Chat system for per-MOC collaboration.
File: src/app/api/chat/route.tsx
GET — Fetch chat messages
Authentication: Required
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
chat_id | string | Yes | Chat room ID |
Response:
{
"chatData": {
"_id": "...",
"messages": [
{ "sender": "userId", "message": "Hello", "timestamp": "2026-02-15T10:30:00Z" }
]
},
"user": { "_id": "...", "name": "..." }
}
POST — Send a message
Request body:
{
"chat_id": "...",
"message": {
"sender": "userId",
"message": "Implementation is progressing well",
"timestamp": "2026-02-15T10:30:00Z"
}
}
GET /api/auto_reminder
Automated reminder system that finds MOCs with upcoming or overdue target timelines and sends urgency-graded email reminders.
Authentication: None (designed to be called by a Vercel cron job)
File: src/app/api/auto_reminder/route.ts
Trigger: Called daily at 08:00 UTC via Vercel cron (configured in vercel.json).
Reminder criteria:
| Condition | Urgency Level |
|---|---|
| Overdue by ≤14 days | CRITICAL |
| Due tomorrow | URGENT |
| Due within 1 week | HIGH |
| Due within 1 month (created >30 days ago) | MEDIUM / LOW |
Side effects:
- Scans all implementer forms with target timeline dates
- Skips completed MOCs
- Sends urgency-graded emails to all MOC users
Response:
{
"message": "Reminders processed",
"totalReminders": 5,
"results": [
{ "moc_id": "...", "serial_num": "15-2026", "urgency": "HIGH", "emailsSent": 3 }
]
}
GET /api/proxy
Image proxy that fetches external images and serves them with CORS headers.
Authentication: None
File: src/app/api/proxy/route.ts
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | External image URL to proxy |
Response: Raw image buffer with Content-Type: image/png, CORS headers, and a 1-year cache duration.
GET/POST/PUT /api/year-end-review
CRUD for year-end HSEQ review documents.
Authentication: None (protected at the page level by middleware)
File: src/app/api/year-end-review/route.ts
GET — Fetch reviews
- With
idquery param → returns a specific review - Without
id→ returns all reviews
POST — Create a review
Request body: Review document data (sections, participants, MOC summary, effectiveness, improvements, issues, actions).
PUT — Update a review
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Review ID |
Request body: Updated review data.
POST /api/createImplementer
Creates or updates an implementer form for a MOC and assigns the approver.
Authentication: Required
File: src/app/api/createImplementer/route.ts
Request body:
{
"moc_id": "...",
"implementer_form": {
"approver-name": { "value": "userId" }
}
}
POST /api/newImplementer
Creates a new MOC with originator form, chat room, and implementer assignment. Legacy endpoint.
Authentication: Required
File: src/app/api/newImplementer/route.tsx
GET/POST/PUT /api/implementer
Basic CRUD for implementer form documents.
File: src/app/api/implementer/route.tsx
| Method | Purpose |
|---|---|
| POST | Create implementer form and link to MOC |
| PUT | Update implementer's MOC reference |