Obs Middleware
Interfaces
Interfaces
ObsMiddlewareOptions
Configuration options for createObsMiddleware
Properties:
| Property | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | Unique identifier for this service (e.g., 'rxdb-server') |
serviceName | string | undefined | No | Human-readable service name (defaults to projectId) |
version | string | undefined | No | Service version (e.g., '1.0.0') |
ResolvedConfig
Resolved configuration with environment defaults applied
Properties:
| Property | Type | Required | Description |
|---|---|---|---|
projectId | string | Yes | |
serviceName | string | Yes | |
version | string | Yes | |
serverUrl | string | Yes | |
apiKey | string | undefined | Yes | |
enabled | boolean | Yes | |
logLevel | LogLevel | Yes | |
batchSize | number | Yes | |
flushInterval | number | Yes |
RequestContext
Request context stored in AsyncLocalStorage
Properties:
| Property | Type | Required | Description |
|---|---|---|---|
requestId | string | Yes | Unique request ID |
traceId | string | undefined | No | Trace ID for cross-service tracing |
userId | string | undefined | No | User ID from authentication |
domainId | string | undefined | No | Domain ID for multi-tenancy |
startTime | number | Yes | Request start timestamp |
LogEntry
Structured log entry
Properties:
| Property | Type | Required | Description |
|---|---|---|---|
level | LogLevel | Yes | |
message | string | Yes | |
data | Record<string, unknown> | undefined | No | |
context | RequestContext | undefined | No | |
timestamp | string | Yes | |
service | string | Yes | |
version | string | Yes |
Logger
Logger interface
HealthCheckResult
Health check result for a single check
Properties:
| Property | Type | Required | Description |
|---|---|---|---|
healthy | boolean | Yes | |
details | Record<string, unknown> | undefined | No | |
error | string | undefined | No |
CustomHealthCheck
Custom health check definition
Properties:
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | |
check | () => Promise<HealthCheckResult> | Yes |
HealthCheckOptions
Options for the health check endpoint
Properties:
| Property | Type | Required | Description |
|---|---|---|---|
customChecks | CustomHealthCheck[] | undefined | No |
HealthCheckResponse
Full health check response
Properties:
| Property | Type | Required | Description |
|---|---|---|---|
status | "healthy" | "degraded" | "unhealthy" | Yes | |
checks | Record<string, HealthCheckResult> | Yes | |
timestamp | string | Yes |
ObsMiddlewareSuite
The middleware suite returned by createObsMiddleware
Properties:
| Property | Type | Required | Description |
|---|---|---|---|
asyncContext | Middleware | Yes | Async context middleware - attach first |
requestLogger | Middleware | Yes | Request logging middleware |
errorHandler | ErrorMiddleware | Yes | Error handler middleware - attach last |
logger | Logger | Yes | Structured logger instance |
healthCheck | (options?: HealthCheckOptions) => (req: Request, res: Response) => Promise<void> | Yes | Health check endpoint factory |