0.4.2 • Published 10 months ago

@sndo/nats-nest v0.4.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

nats-nest

nats-nest is a thin wrapper around an embedded NATS server in a Go module. A server can be started through the command-line or using the NatsServer class, which basically just invokes the nats-server executable.

Installation

npm install @sndo/nats-nest

CLI Usage

A NATS server can be started like so:

npx nats-nest

NatsServer Usage

A NatsServer class can also be used to start a server.

import { NatsServer } from 'nats-nest'

const server = new NatsServer()

// The options are optional
await server.start({
  host: '127.0.0.1',
  port: 4222,
  name: 'NATS_Server',
  jetstream: true,
})

// Stopping the server
await server.stop()

Configuration Options

Server config options can also be set when starting the server.

FieldTypeFlag(s)Environment VariableDefaultHelp
Hoststring-h, --hostNATS_NEST_HOST0.0.0.0Host on which the NATS server will listen
Portint-p, --portNATS_NEST_PORT4222Port on which the NATS server will listen
HTTPPortint-m, --http-portNATS_NEST_HTTP_PORTHTTP port for monitoring dashboard (exclusive of --https-port)
HTTPSPortint--https-portNATS_NEST_HTTPS_PORTHTTPS port for monitoring dashboard (exclusive of --httpx-port)
Namestring-n, --nameNATS_NEST_NAMEServer name
PidFilestring-P, --pidNATS_NEST_PIDFile to write the server's PID
Configstring-c, --configNATS_NEST_CONFIGPath to configuration file
LogFilestring-l, --logFile to redirect log output
NoLogbool--no-logNATS_NEST_NO_LOGDisable logging
Debugbool-D, --debugNATS_NEST_DEBUGEnable debug mode
Syslogbool-s, --syslogLog to syslog or windows event log
Jetstreambool--jetstreamEnable JetStream functionality
StoreDirstring--store_dirSet the storage directory

Examples:

Setting a name and enabling Jetsream

npx nats-nest --name "MyNatsServer" --jetstream

Setting the port and host

npx nats-nest --port 4222 --host 127.0.0.1
0.4.2

10 months ago

0.4.1

11 months ago

0.4.0

11 months ago

0.3.8

11 months ago

0.3.7

11 months ago

0.3.6

11 months ago

0.3.5

11 months ago

0.3.4

11 months ago

0.3.3

11 months ago

0.3.2

11 months ago

0.3.1

11 months ago

0.3.0

11 months ago

0.2.0

11 months ago

0.1.0

11 months ago