New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@egodigital/microservices

Package Overview
Dependencies
Maintainers
3
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@egodigital/microservices

Shared library for microservices, written for Node.js

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

npm

@egodigital/microservices

Shared library for microservices, written for Node.js, in TypeScript.

Install

Execute the following command from your project folder, where your package.json file is stored:

npm install --save @egodigital/microservices

Usage

Constants
NameDescriptionExample
JWT_SECRETThe secret for signing and validating JWT.mySecretJWTSecret
NATS_CLUSTER_IDThe name of the cluster, that contains this and the other microservices.ego-microservice-cluster
NATS_GROUPThe name of the pod group / kubernetes deployment.my-service-or-deployment
NATS_URLThe URL to the NATS server.http://my-nats-service:4222
POD_NAMEThe name of the pod. This should come as imported metadata from Kubernetes.my-service-or-deployment-XCSGBxV

Express

JWT
import express from 'express';
import { withJWT } from '@egodigital/microservices';

const app = express();

app.get('/', withJWT(), async (request, response) => {
    // decoded, valid user token is stored in:
    // request.userToken
});

app.listen(4242, () => {
    console.log('Service is listening ...');
});

NATS

import { stan } from '@egodigital/microservices';

await stan.connect();
stan.exitOnClose();
Listener
import { stan } from '@egodigital/microservices';

interface IMyEvent {
    foo: string;
    bar: number;
}

const myEventListener = new NatsListener('my.event');

myEventListener.onMessage = (context) => {
    // handle message in context.message of type IMyEvent
};

myEventListener.listen();
Publisher
import { stan } from '@egodigital/microservices';

interface IMyEvent {
    foo: string;
    bar: number;
}

const myEventPublisher = new NatsPublisher('my.event');

myEventPublisher.publish({
    foo: "TM+MK",
    bar: 42
});

Documentation

The API documentation can be found here.

Keywords

FAQs

Package last updated on 17 Feb 2021

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