Files
adam-acs/start/env.ts
T
Kevin L'Hereec 0c83a4ccb2 feat: TR-069 Exchange Viewer - structured MongoDB storage with SSE streaming and sequence diagram UI
- MongoDB storage: cwmp_exchanges collection with indexes (deviceId+timestamp, deviceId+sequenceNumber unique, TTL 24h)
- ExchangeStoreService: CWMP method extraction, per-device queue for ordering, retry logic, message cap (5000/device)
- Exchange API: GET/DELETE/SSE stream endpoints with Last-Event-ID reconnection
- CwmpLoggerMiddleware: dual-write (MongoDB + legacy files) with fire-and-forget
- Frontend: SequenceViewer (CPE↔ACS lifelines, arrows, auto-scroll, virtual scroll) + InspectorPanel (formatted XML, copy, syntax highlighting)
- Tr069Trace page: integrated new viewer with col-6/col-6 layout
- DeviceDetail page: collapsible exchange section when device is traced
- 14 property-based tests, 40+ unit tests, 5 integration tests
- Health check includes index verification
- Config: feature flags, SSE timeouts, retry policy
2026-06-03 15:52:44 +02:00

60 lines
2.2 KiB
TypeScript

/*
|--------------------------------------------------------------------------
| Environment variables service
|--------------------------------------------------------------------------
|
| The `Env.create` method creates an instance of the Env service. The
| service validates the environment variables and also cast values
| to JavaScript data types.
|
*/
import { Env } from '@adonisjs/core/env'
export default await Env.create(new URL('../', import.meta.url), {
// Node
NODE_ENV: Env.schema.enum(['development', 'production', 'test'] as const),
PORT: Env.schema.number(),
HOST: Env.schema.string({ format: 'host' }),
LOG_LEVEL: Env.schema.string(),
// App
APP_KEY: Env.schema.secret(),
APP_URL: Env.schema.string({ format: 'url', tld: false }),
// Session
SESSION_DRIVER: Env.schema.enum(['cookie', 'memory'] as const),
// MongoDB
MONGODB_URI: Env.schema.string(),
MONGODB_DB_NAME: Env.schema.string.optional(),
// Observability
OTEL_EXPORTER_URI: Env.schema.string.optional(),
OTEL_SAMPLER_MODE: Env.schema.string.optional(),
OTEL_SAMPLER_RATIO: Env.schema.string.optional(),
OTEL_SERVICE_NAME: Env.schema.string.optional(),
// Remote logging
LOG_HOST: Env.schema.string.optional(),
LOG_PORT: Env.schema.number.optional(),
LOG_PROTOCOL: Env.schema.string.optional(),
// Security
HASH_KEY: Env.schema.string.optional(),
// Exchange Store
EXCHANGE_STORE_MAX_MESSAGES: Env.schema.number.optional(),
EXCHANGE_STORE_TTL_SECONDS: Env.schema.number.optional(),
EXCHANGE_STORE_SSE_INACTIVITY_TIMEOUT_MS: Env.schema.number.optional(),
EXCHANGE_STORE_SSE_ABSOLUTE_TIMEOUT_MS: Env.schema.number.optional(),
EXCHANGE_STORE_SSE_MAX_CONNECTIONS_PER_DEVICE: Env.schema.number.optional(),
EXCHANGE_STORE_SSE_RETRY_INTERVAL_MS: Env.schema.number.optional(),
EXCHANGE_STORE_RETRY_MAX_ATTEMPTS: Env.schema.number.optional(),
EXCHANGE_STORE_RETRY_BASE_DELAY_MS: Env.schema.number.optional(),
EXCHANGE_STORE_READ_TIMEOUT_MS: Env.schema.number.optional(),
FEATURE_EXCHANGE_PERSISTENCE: Env.schema.boolean.optional(),
FEATURE_SSE_ENABLED: Env.schema.boolean.optional(),
FEATURE_EXCHANGE_API_SOURCE: Env.schema.enum.optional(['mongodb', 'file'] as const),
})