npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

infra-notification-sender

v1.2.0

Published

The lambda function `infra-notification-sender` is connected to the queue `infra-notification-sender` where it gets the messages about events that ocurred, and then based on the tenants configuration and the event type an email with the relevant informati

Downloads

2

Readme

infra-notification-sender

The lambda function infra-notification-sender is connected to the queue infra-notification-sender where it gets the messages about events that ocurred, and then based on the tenants configuration and the event type an email with the relevant information will be sent to the address configured for the tenant.

For the PoC the tenants configuration is provided as JSON in an environment variable called TENANTS_CONFIG, but in the future this configuration will be stored in the Customer DB.

You can see the expected structure for a single tenant config in types.ts Currently the configurations follow this structure:

{
  "{tenantName}": TENANT_CONFIG <--- see types.ts
  ...
}

For the future implementation these are the points to consider:

  • The Nordsense domain needs to be validated as a trusted one for AWS SES.
  • Metrics like emails bounce rate should be added to the alarms and maybe to the dashboards.
CREATE TABLE IF NOT EXISTS public.tenant_notification_configuration (
  "tenant_id" TEXT UNIQUE NOT NULL,
  "emails" TEXT[] NOT NULL,
  "supported_types" TEXT[] NOT NULL,
  "locale" TEXT DEFAULT NULL
);

Example payload (See Notification in types.ts)

{
  "tenant": "test-playground",
  "type": "fire",
  "containerId": "1234"
}

The specific expected data depends on the type, so you can look at those to see which data we expect.

Scripts

Test

npm run test - runs the tests once

npm run watch:test - watches files and tests for changes and re-runs them

Preview Templates

npm run watch:templates

We use MJML and Handlebars. For the best development workflow with VSCode use the daniel knight fork of the MJML extension (danielknights.vscode-mjml), as it adds a way to persist the MJML file preview. See the settings in .vscode/settings.json. Note that the preview file needs to stay open in your editor somewhere, otherwise the preview will switch.

Watching the templates will output all templates in all supported locales into templatePreviews.

Make sure to review templates in all languages, especially an RTL vs LTR locale (f.ex. en-US vs he-IL).

Build

npm run build:staging - will run the tests, then build the output .zip into Terraform Staging Assets

npm run build:prod - will run the tests, then build the output .zip into Terraform Prod Assets

Release

npm run release:staging - runs the staging build and thereafter releases to staging terraform

npm run release:prod - runs the production build and thereafter releases to production terraform

Note that these commands require Terraform

Table schema

CREATE TABLE public.notification_events (
  id uuid NOT NULL PRIMARY KEY,
  tenant_id TEXT NOT NULL,
  sent_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
  event_timestamp TIMESTAMP WITH TIME ZONE NOT NULL,
  type TEXT NOT NULL,
  resource_id TEXT NOT NULL
);
CREATE UNIQUE INDEX notification_events_type_resource_id_event_timestamp_idx
  ON public.notification_events USING btree (type, resource_id, event_timestamp);
CREATE INDEX notification_events_tenant_id_event_timestamp_idx
  ON public.notification_events USING btree (tenant_id, event_timestamp);
CREATE INDEX notification_events_event_timestamp_idx
  ON public.notification_events USING btree (event_timestamp);
ALTER TABLE public.notification_events
	OWNER TO junk;