Skip to content

gabel/keyv-nats

Repository files navigation

keyv-nats

NATS storage adapter for the awesome keyv.

build codecov GitHub license npm

Installation

yarn add keyv keyv-nats

Usage

import Keyv from 'keyv'
import KeyvNats from 'keyv-nats'

const keyvNats = new KeyvNats({ servers: "localhost:4222" });
await keyvNats.connect();
const keyv = new Keyv({ store: keyvNats })

const key = 'foo'
const value = 'bar'

await keyv.set(key, value)

await keyv.get(key)

keyvNats.disconnect();

Tests

NATS Keyv storage adapter uses Testcontainers for NodeJS in order to run NATS server during test automation. Please check general Docker requirements of Testcontainers to run those in your local docker environment.

# nothing else required as testcontainer will start and stop nats
yarn test