🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More
Socket
Book a DemoSign in
Socket

@first-lego-league/ms-correlation

Package Overview
Dependencies
Maintainers
5
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@first-lego-league/ms-correlation

A library to help support MS with domains

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
5
Created
Source

npm David Dependency Status David Dev Dependency Status David Peer Dependencies Status Build status GitHub

FIRST LEGO Legaue Correlation

A library for supporting FIRST LEGO League TMS Module Standard correlation section.

Usage

There are two options to use this library: with middleware or with domain.

Usage with middleware

When having frameworks like express that support middlewares. You can use the middleware correlationMiddleware this middleware will also take care of authentication.

Usage with domain

When not using the middleware you should open a new domain in your code, and use the function correlateSession. For example:

const Domain = require('domain')

const { correlateSession } = require('@first-lego-league/ms-correlation')

someEventEmitter.on('someEvent', event => {
  const correlationId = getCorrelationId(event)
  const authToken = getAuthToken(event)

  Domain.create().run(() => {
    correlateSession(correlationId, authToken)

    handleEvent(event)
  })
})

Be aware that both argument of this function are optionals.

Retrieving correlation data

You can use the function getCorrelationId and getAuthenticationData to retrive data on the current session.

Contribution

To contribute to this repository, simply create a PR and set one of the Code Owners to be a reviewer. Please notice the linting and UT, because they block merge. Keep the package lightweight and easy to use. Thank you for contributing!

FAQs

Package last updated on 17 Dec 2019

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