Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nats-micro

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nats-micro

### Description

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13
decreased by-88.18%
Maintainers
1
Weekly downloads
 
Created
Source

NATS Microservice Library

Tiny microservice library based on NATS

and compatible with nats-go microservices

Description

This is a typescript-first library that provides a convinient (in 10 lines of code or less!) way to write microservises with out of the box auto discovery, observability and load balancing.

Full interoperability with to-be-released nastcli v0.0.36 that adds nats micro info, nats micro stats and nats micro ping commands

Limitations / TODO

  1. No multi-reply support yet. When you send a message you will be getting exactly one response (or a timeout error)
  2. No microservice and endpoint name validation
  3. (WIP) Zod library is used for method arguments and result typing. However:
  4. No actual validation is implemented yet.
  5. No microservice interface discovery is specified in the current version of nats micro protocol thus method interface cannot be discovered over NATS yet.

Usage

It is extremely simple:

  const broker = await new Broker('echo' + process.pid).connect();
  
  await Microservice.create(
    broker,
    {
      name: 'echo-service',
      description: 'Simple echo microservice',
      version: '0.0.1',
      methods: {
        echo: {
          handler: (text) => text,
          // subject is autogenerated according to nats micro protocol
        },
        'config-change-event': {
          handler: console.log,
          // subject is manually specified which allows for broadcast
          // event bus
          subject: '$EVT.config.change',
        },
      },
    }
  );

FAQs

Package last updated on 24 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc