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

event-mapper

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-mapper

[![Node.js CI](https://github.com/fazley-kholil-cko/event-mapper/actions/workflows/node.js.yml/badge.svg?branch=master)](https://github.com/fazley-kholil-cko/event-mapper/actions/workflows/node.js.yml)

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
decreased by-67.57%
Maintainers
1
Weekly downloads
 
Created
Source

Node.js CI

event-mapper

About

Utility to map a dto to an event based on a json mapping definition.

Installation

$ npm install --save event-mapper

Usage

1.First of all create a folder and define some mapping definition files.

  • The Name field is the name of the event.
  • The Mapping object defines the fields that needs to be mapped from the dto to the event
{
    "Name": "TestEvent1",
    "Mapping": {
        "Field1": "FieldDest1",
        "Field2": "FieldDest2",
        "Field3": "SchemeData.FieldDest3"
    }
}

2.In your app, add the required dependencies and initialise the library for it to compile the mapping files.

var eventMapper = require('event-mapper');

var mappers = eventMapper.init('./test-definitions/');

    var dto = {
        "Field1": "12345",
        "Field2": "99999912345X",
        "Field3": 200
    };

var event = eventMapper.map(dto, mappers['TestEvent1']);

console.log(event);

//returns a structured json containing the event
// {
//   TestEvent1: {
//     FieldDest1: '12345',
//     FieldDest2: '99999912345X',
//     SchemeData: { FieldDest3: 200 }
//   }
// }

console.log(event.TestEvent1.SchemeData.FieldDest3);

//200


//Generating an event hash - eventMapper.generateEventHash('string_here')
var hash = eventMapper.generateEventHash('TestEvent1_65d6b12c-68a3-4518-a863-8082c3443410_19e72db8-dfd6-4bd4-92a5-8e8ba43455c1');
console.log(hash);

//output: 
//5a7210728bd4f27c0a142fc8ac808918

FAQs

Package last updated on 12 Jul 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