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

emittableevent

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emittableevent

EmittableEvent is an opinionated abstraction class for generating rich EventBridge events.

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
111
decreased by-58.11%
Maintainers
1
Weekly downloads
 
Created
Source

EmittableEvent

EmittableEvent is an opinionated abstraction class for generating rich EventBridge events.

Build Status

Quality Gate Status

codecov

Maintainability


Note that EmittableEvent is primarily meant to function in an AWS Lambda context, however it will function just fine also outside of one but will be missing certain metadata.

For a great complementary solution for a Domain Event Publisher and an Event Emitter abstraction using EmittableEvent, see my related Gist.

Usage

Basic importing and usage

// ES5 format
const { EmittableEvent } = require('emittableevent');
// ES6 format
import { EmittableEvent } from 'emittableevent';

class MyEvent extends EmittableEvent {
  // Do something here if you want, else just leave it as is!
}

const event = new MyEvent(eventInput, awsRequestContext);

Demo

// Your own event class
class MyEvent extends EmittableEvent {
  // Do something here if you want, else just leave it as is!
}

// Convenience utility to produce required static metadata
const getMetadataConfig = (version = 1) => {
  return {
    version,
    eventType: 'DomainEvent',
    domain: 'MyDomain',
    system: 'MySystem',
    service: 'MyService',
    team: 'MyTeam',
    hostPlatform: 'aws',
    owner: 'Sam Person',
    jurisdiction: 'eu'
  };
};

// Input for actually creating the event
const eventInput = {
  eventName: 'MyEvent',
  eventBusName: 'MyEventBus',
  data: {
    something: 'some value here if you want'
  },
  metadataConfig: getMetadataConfig()
};

// Create the event
const event = new MyEvent(eventInput, requestContext);

// ...and here's the actual full body of the event
console.log(event.get());

The event will look similar to:

{
  "EventBusName": "MyEventBus",
  "Source": "mydomain.mysystem.myevent",
  "DetailType": "MyEvent",
  "Detail": "{\"metadata\":{\"version\":1,\"eventType\":\"DomainEvent\",\"domain\":\"MyDomain\",\"system\":\"MySystem\",\"service\":\"MyService\",\"team\":\"MyTeam\",\"hostPlatform\":\"aws\",\"owner\":\"Sam Person\",\"jurisdiction\":\"eu\",\"eventName\":\"MyEvent\",\"correlationId\":\"26dd1faf-a901-4413-92db-9e09b7915a3c\",\"resource\":\"/\",\"accountId\":\"123412341234\",\"runtime\":\"\",\"functionName\":\"\",\"functionMemorySize\":\"\",\"functionVersion\":\"\",\"lifecycleStage\":\"dev\",\"region\":\"\"},\"data\":{\"something\":\"some value here\"}}"
}

Keywords

FAQs

Package last updated on 26 Oct 2022

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