@markwylde/eventbase
Version:
A distributed, event-sourced, key-value database built on top of **NATS JetStream**. Eventbase provides a simple yet powerful API for storing, retrieving, and subscribing to data changes, with automatic state synchronization across distributed instances a
22 lines • 641 B
JavaScript
import { connect } from "@nats-io/transport-node";
import { jetstream, jetstreamManager } from "@nats-io/jetstream";
export async function setupNats(streamName, options) {
const nc = await connect(options);
const js = jetstream(nc);
const jsm = await jetstreamManager(nc);
// Ensure stream exists
try {
await jsm.streams.info(streamName);
}
catch {
await jsm.streams.add({
name: streamName,
subjects: [`${streamName}.*`]
});
}
const close = async () => {
await nc.close();
};
return { nc, js, jsm, close };
}
//# sourceMappingURL=nats.js.map