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

0.0.0 • Public • Published

NATS Server

This tool bootstraps a NATS server/cluster for development purposes. Inspired by this repo. DO NOT USE FOR PRODUCTION

Author

onichandame

Usage

Installation(downloads NATS server binary if not found in path):

yarn add -D nats-server

Test scripts:

import { Server, Cluster } from 'nats-server'
import { connect } from 'ts-nats'
 
describe("module1", () => {
  const server: Server
  const cluster: Cluster
  beforeAll(() => {
    server = new Server()
    cluster = new Cluster()
  })
  test("can connect to NATS", async done => {
    let nc = await connect(await server.getUri())
    nc = await connect({servers: await cluster.getUris()})
    console.log("Able to connect to the test NATS cluster!")
    done()
  })
  afterAll(async () => {
    await server.stop()
    await cluster.stop()
  })
})

Known Issues

  1. does not support Windows. May work on OSX(not tested as I do not possess a Mac)
  2. Not fully tested yet so there may be server instances dangling around after the main process exits abnormally. Make sure you call await server.stop() to clean it up and check ps aux | grep nats-server if process exits before server.stop() is resolved.
  3. requires to open ports between 10000 and 12000. This limit is hard coded for now. Let me know if a customization is desirable.

Readme

Keywords

none

Package Sidebar

Install

npm i nats-server

Weekly Downloads

0

Version

0.0.0

License

MIT

Unpacked Size

255 kB

Total Files

21

Last publish

Collaborators

  • onichandame