Obs Middleware

Interfaces

Interfaces

ObsMiddlewareOptions

Configuration options for createObsMiddleware

Properties:

PropertyTypeRequiredDescription
projectIdstringYesUnique identifier for this service (e.g., 'rxdb-server')
serviceNamestring | undefinedNoHuman-readable service name (defaults to projectId)
versionstring | undefinedNoService version (e.g., '1.0.0')

ResolvedConfig

Resolved configuration with environment defaults applied

Properties:

PropertyTypeRequiredDescription
projectIdstringYes
serviceNamestringYes
versionstringYes
serverUrlstringYes
apiKeystring | undefinedYes
enabledbooleanYes
logLevelLogLevelYes
batchSizenumberYes
flushIntervalnumberYes

RequestContext

Request context stored in AsyncLocalStorage

Properties:

PropertyTypeRequiredDescription
requestIdstringYesUnique request ID
traceIdstring | undefinedNoTrace ID for cross-service tracing
userIdstring | undefinedNoUser ID from authentication
domainIdstring | undefinedNoDomain ID for multi-tenancy
startTimenumberYesRequest start timestamp

LogEntry

Structured log entry

Properties:

PropertyTypeRequiredDescription
levelLogLevelYes
messagestringYes
dataRecord<string, unknown> | undefinedNo
contextRequestContext | undefinedNo
timestampstringYes
servicestringYes
versionstringYes

Logger

Logger interface

HealthCheckResult

Health check result for a single check

Properties:

PropertyTypeRequiredDescription
healthybooleanYes
detailsRecord<string, unknown> | undefinedNo
errorstring | undefinedNo

CustomHealthCheck

Custom health check definition

Properties:

PropertyTypeRequiredDescription
namestringYes
check() => Promise<HealthCheckResult>Yes

HealthCheckOptions

Options for the health check endpoint

Properties:

PropertyTypeRequiredDescription
customChecksCustomHealthCheck[] | undefinedNo

HealthCheckResponse

Full health check response

Properties:

PropertyTypeRequiredDescription
status"healthy" | "degraded" | "unhealthy"Yes
checksRecord<string, HealthCheckResult>Yes
timestampstringYes

ObsMiddlewareSuite

The middleware suite returned by createObsMiddleware

Properties:

PropertyTypeRequiredDescription
asyncContextMiddlewareYesAsync context middleware - attach first
requestLoggerMiddlewareYesRequest logging middleware
errorHandlerErrorMiddlewareYesError handler middleware - attach last
loggerLoggerYesStructured logger instance
healthCheck(options?: HealthCheckOptions) => (req: Request, res: Response) => Promise<void>YesHealth check endpoint factory
Previous
API Reference
Next
Types