@bridgebase/core
v0.2.1
Published
BridgeBase Core - Shared session management, gateway resolution, and proxy lifecycle
Maintainers
Readme
@bridgebase/core
Core BridgeBase SDK - Shared session management, gateway resolution, and proxy lifecycle.
Features
- Session Management - Base session orchestration for all database types
- Gateway Resolution - Dynamic gateway discovery with JWT authentication
- Local Proxy Management - TCP proxy lifecycle and routing
- Exception Hierarchy - Comprehensive error handling
- Type Safety - Full TypeScript support
Installation
npm install @bridgebase/coreUsage
import {
BaseSession,
GatewayResolutionError,
ConnectionError,
} from "@bridgebase/core";
// Core is typically used by adapter packages, not directly by users
// See @bridgebase/redis or @bridgebase/tigerbeetle for user-facing APIsArchitecture
Components
- BaseSession - Abstract base for all session implementations
- GatewayResolver - Resolves database gateway from control plane
- GatewayConnection - Manages TCP connection with JWT authentication
- ProxyManager - Local proxy lifecycle and port allocation
- Exception Hierarchy - Typed error handling
Connection Flow
Application
↓
Session.connect()
↓
GatewayResolver.resolve(JWT)
↓
BridgeBase Control Plane (validates token, returns gateway address)
↓
GatewayConnection.establish()
↓
Local Proxy (TCP tunneling to remote database)
↓
connectNative() (adapter-specific, e.g., Redis client)
↓
Native Client ReadyError Handling
import {
AuthError,
GatewayResolutionError,
ConnectionError,
ProxyError,
} from "@bridgebase/core";
try {
const session = new SomeSession(config);
await session.connect();
} catch (error) {
if (error instanceof AuthError) {
console.error("Authentication failed");
} else if (error instanceof GatewayResolutionError) {
console.error("Gateway resolution failed");
} else if (error instanceof ConnectionError) {
console.error("Connection failed");
}
}License
MIT
