mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-17 00:19:41 +02:00
Replaces the NestJS mana-notify service with a Go implementation. Features: 4 notification channels (email/SMTP, Expo push, Matrix, webhook), goroutine worker pool with retry/backoff (replaces BullMQ), Go template engine (replaces Handlebars), PostgreSQL with auto-migrations (5 tables), user preferences with quiet hours, idempotency via externalId, batch sending, scheduled delivery, JWT + service key auth. 22 API endpoints, 1:1 compatible. Binary: 21 MB. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
24 lines
511 B
Go
24 lines
511 B
Go
package handler
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
func writeJSON(w http.ResponseWriter, status int, data any) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.WriteHeader(status)
|
|
json.NewEncoder(w).Encode(data)
|
|
}
|
|
|
|
func writeError(w http.ResponseWriter, status int, message string) {
|
|
writeJSON(w, status, map[string]any{
|
|
"success": false,
|
|
"error": map[string]any{
|
|
"statusCode": status,
|
|
"message": message,
|
|
"timestamp": time.Now().UTC().Format(time.RFC3339),
|
|
},
|
|
})
|
|
}
|