@oneplatform/core
@oneplatform/core¶
@oneplatform/core — Shared infrastructure for all OnePlatform services.
Every service imports from this package rather than from internal paths. It provides the Hono app factory, database/Redis clients, BullMQ queue helpers, structured logging, middleware stack, error hierarchy, and configuration loader.
Typical service bootstrap¶
import { createApp, loadConfig, createDbClient, createRedisClient } from '@oneplatform/core';
const config = loadConfig();
const redis = createRedisClient({ url: config.OP_REDIS_URL });
const db = createDbClient({ connectionString: config.OP_DATABASE_URL, maxConnections: 10 });
const app = createApp({
serviceName: 'my-service',
version: '1.0.0',
jwtSecret: config.OP_JWT_SECRET,
redis,
validateApiKey: async (key) => { ... },
allowedOrigins: config.OP_ALLOWED_ORIGINS,
publicRoutes: ['/healthz', '/readyz'],
targetService: 'my-service',
servicePublicKeys: {},
});
Enumerations¶
Classes¶
- AppError
- BulkLimitExceededError
- ConflictError
- CursorExpiredError
- EntityNotFoundError
- ForbiddenError
- InsufficientScopeError
- InternalError
- InvalidCursorError
- NotFoundError
- OriginNotAllowedError
- PaginationLimitExceededError
- PermissionDeniedError
- RateLimitError
- ServiceUnavailableError
- UnauthorizedError
- UnknownFilterFieldError
- UnsortableFieldError
- ValidationError
Interfaces¶
- ApiError
- ApiResponse
- AuditEvent
- AuthMiddlewareConfig
- CorsConfig
- CreateAppConfig
- DataEnvelope
- DbClientConfig
- DeprecationInfo
- ErrorHandlerConfig
- EventPublisher
- EventPublisherConfig
- HealthConfig
- LogEvent
- Logger
- LoggerConfig
- PaginatedResponse
- PlatformEvent
- RateLimitInfo
- ReadyzConfig
- RedisClientConfig
- ServiceAuthConfig
- ServiceTokenSigner
- UserContext
Type Aliases¶
- AppServiceConfig
- AppVariables
- AuthConfig
- BaseConfig
- ExecutionConfig
- GatewayConfig
- IngestionConfig
- LoggingConfig
- LogLevel
- OntologyConfig
- PipelineConfig
- PluginServiceConfig
Variables¶
- appConfigSchema
- authConfigSchema
- baseConfigSchema
- cronExpressionSchema
- executionConfigSchema
- gatewayConfigSchema
- ingestionConfigSchema
- loggingConfigSchema
- ontologyConfigSchema
- pipelineConfigSchema
- pluginConfigSchema
Functions¶
- authMiddleware
- corsMiddleware
- createApp
- createDbClient
- createDlqQueue
- createEventPublisher
- createLogger
- createQueue
- createRedisClient
- createServiceTokenSigner
- createWorker
- decodeCursor
- decrypt
- deprecationHeadersMiddleware
- encodeCursor
- encrypt
- errorHandlerMiddleware
- healthz
- isServiceCallAllowed
- isValidCronExpression
- loadConfig
- loadMasterKey
- loadServicePrivateKey
- rateLimitHeadersMiddleware
- readyz
- requestIdMiddleware
- responseEnvelopeMiddleware
- serviceAuthMiddleware
- setTenantContext
- setupProcessErrorHandlers