@traxx-tech/event-stream
v0.5.5
Published
Official TypeScript SDK for publishing and consuming events
Maintainers
Readme
Traxx Event Stream SDK
The SDK provides a simple interface for publishing and consuming events through Traxx Event Stream.
Installation
npm install @traxx-tech/event-streamRequires Node.js 20+.
Quick Start
import {
EventStreamClient,
EventStreamEnvironment,
} from '@traxx-tech/event-stream';
const client = new EventStreamClient({
environment: EventStreamEnvironment.DEVELOPMENT,
applicationId: process.env.EVENT_STREAM_APPLICATION_ID!,
apiKey: process.env.EVENT_STREAM_API_KEY!,
serviceName: 'backend-service',
});
await client.connect();Publish Events
import { randomUUID } from 'node:crypto';
await client.publish({
eventId: randomUUID(),
eventName: 'EMPLOYEE_CREATED',
eventVersion: 1,
topic: 'octahr.employee.events.v1',
messageKey: 'employee-001',
occurredAt: new Date().toISOString(),
payload: {
employeeId: 'employee-001',
name: 'Brixt ix ',
},
});Subscribe to Events
const subscription = await client.subscribe({
topic: 'octahr.employee.events.v1',
eventNames: ['EMPLOYEE_CREATED'],
eventVersions: [1],
handler: async (event) => {
console.log('Event received:', event.payload);
},
});The SDK automatically handles delivery acknowledgements and reports handler failures to Traxx Event Stream.
Typed Subscriptions
interface EmployeeCreatedPayload {
employeeId: string;
name: string;
}
await client.subscribe<EmployeeCreatedPayload>({
topic: 'octahr.employee.events.v1',
eventNames: ['EMPLOYEE_CREATED'],
eventVersions: [1],
handler: async (event) => {
console.log(event.payload.employeeId);
console.log(event.payload.name);
},
});Unsubscribe
await subscription.unsubscribe();Shutdown
Close the client when the application shuts down:
client.close();Requirements
- Node.js 20 or later
- Registered application ID
- Valid API key
Versioning
This project follows Semantic Versioning (SemVer).
License
MIT License © 2026 Traxx Technology
