Appearance
Shared Package (@ce-sdr/shared)
Located at packages/shared/, this package provides common Express middleware, logging, and environment validation used across apps/app, apps/worker, and apps/cloudwatch.
Contents
Middleware
| Export | Purpose |
|---|---|
securityMiddleware() | Helmet security headers |
gatewayCors(origins) | CORS configured from ALLOWED_ORIGINS env var |
rateLimiter() | Express rate limiting per IP |
requestLogger(tag) | Structured HTTP request logging with Winston |
healthCheck(tag) | GET /health endpoint handler |
notFoundHandler() | 404 response for unmatched routes |
errorHandler() | Centralized error response formatter |
Logger
Winston logger wrapper. Outputs structured JSON in production, formatted text in development. All log output flows through the @ce-sdr/cloudwatch-client in deployed environments.
Environment Validation
Env vars are validated at startup using Zod schemas via @t3-oss/env-nextjs. Each service defines its required vars and the app will fail fast with a clear error if any are missing or invalid.