nats-memory-server
TypeScript icon, indicating that this package has built-in type declarations

1.4.2 • Public • Published

nats-memory-server

GitHub license GitHub issues GitHub stars

nats-memory-server is a Node.js package that provides an in-memory NATS server for testing and other purposes. It allows you to quickly set up and tear down a NATS server instance within your Node.js applications, making it easier to write tests and perform other operations that require a NATS server.

Features

  • Lightweight and easy to use
  • In-memory NATS server
  • Suitable for testing and local development
  • Zero configuration required
  • Simple API for starting and stopping the server
  • Supports NATS server options

Requirements

  • Go (version 1.19 or later)

Installation

You can install nats-memory-server using npm or yarn:

npm install nats-memory-server

or

yarn add nats-memory-server

Usage

To use nats-memory-server in your Node.js application, follow these steps:

  1. Import the package:
const NatsMemoryServer = require("nats-memory-server");
  1. Instantiate the server:
const server = await NatsMemoryServer.create();
  1. Start the server: if server already start this method throw error
await server.start();
  1. Connect your NATS client to the server:
const NATSClient = require("nats");

const nc = await NATSClient.connect({ servers: server.getUrl() });
  1. Perform your tests or other operations using the connected NATS client.

  2. Stop the server:

await server.stop();

That's it! Now you have an in-memory NATS server running for your application.

For more advanced usage and server options, please refer to the API documentation.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvement, please feel free to open an issue or submit a pull request on the GitHub repository.

When contributing, please ensure to follow the code of conduct.

License

This project is licensed under the MIT License.

Package Sidebar

Install

npm i nats-memory-server

Weekly Downloads

0

Version

1.4.2

License

MIT

Unpacked Size

14.8 kB

Total Files

6

Last publish

Collaborators

  • ll1r1k1337