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

amongo

v1.3.3

Published

A mongodb realm api client to handle and sync migrations.

Downloads

5

Readme

amongo

- trigger migrations among aws and mongodb

This cli package was created to help CI/CD pipelines, keeping in sync mongodb trigger declarations with mongodb platform and reflecting it on aws event-bridge partners section.


# mongodb trigger declarations

This cli abstract most of mongodb trigger configurations, requiring only what you realy need to know about your trigger, also it applies aws event-bridge connection by default to make the integration easier.

You can find all you need to know about mongodb database-triggers on official documentation:

database triggers doc

migration_schema.json

[
    {
        "name": "EVENT_ON_INSERT_USER",
        "operation_types": ["INSERT"],
        "collection": "users"
    },{
        "name": "EVENT_ON_INSERT_ORDER",
        "collection": "orders",
        "operation_types": ["INSERT"],
        "match": { "fullDocument.status": "PENDING" },
        "project": { "fullDocument": 1 },
        "disabled": false,
        "unordered": true,
        "full_document": true,
        "full_document_before_change": false,
        "skip_catchup_events": false,
        "tolerate_resume_errors": false
    }
]

# amongo command cli

# collecting environment variables

  • AWS_REGION = The aws region where you want to register yours event bridges.
  • AWS_ACCOUNT_ID = Your AWS Account ID.
  • MONGODB_GROUP_ID = Can be founded on URL of your mongodb dashboard After select an organization project.
  • MONGODB_APP_ID = Can be founded on URL of your mongodb dashboard when you access your application on AppServices
  • MONGODB_API_KEY = Can be created on your organizanization section at Access Manager section (The permission must to be Organization Owner, pay attention at this part if you get error 403 after authentication!!!)
  • MONGODB_API_SECRET = Auto generated when you create your API KEY on your organizanization section at Access Manager section.
  • MONGODB_CLUSTER_NAME = The cluster name where your database was created.
  • MONGODB_DATABASE = The name of yor database.

# calling amongo coomand

cicd_script.sh

amongo 
--aws_region=${AWS_DEFAULT_REGION}
--aws_account_id=${AWS_ACCOUNT_ID}
--mongodb_group_id=${MONGODB_GROUP_ID}
--mongodb_app_id=${MONGODB_APP_ID}
--mongodb_api_key=${MONGODB_API_KEY}
--mongodb_api_secret=${MONGODB_API_SECRET}
--mongodb_cluster_name=${MONGODB_CLUSTER_NAME}
--mongodb_database=${MONGODB_DATABASE}
--schema=migration_schema.json

After run amongo command cli all database trigger events will be available with Pending status on https://<your-region>.console.aws.amazon.com/events/home?region=<your-region>#/partners and ready to be associated to an event-bus ARN.

image

PS: for development, you can run the run.sh shell file at this project to test in dev mode ASAP. * Dont forget to setting up your credentials on environment variables.

# serverless

After amongo command runs, it exports the trigger names as environment variables with it respective values (aws partner event source name) and store it on the .env files, where it can be used to continue the CI/CD pipeline being imported by serverless.yml and used to trigger lambda functions.

serverless.yml

service: amongo-example
useDotenv: true

plugins:
  - serverless-dotenv-plugin
  
provider:
  name: aws
  stage: ${opt:stage, 'develop'}
  environment:
    EVENT_ON_INSERT_ORDER: ${env:EVENT_ON_INSERT_ORDER}

functions:
  send-order-email:
    name: send-order-email-${self:provider.stage}
    handler: functions/send-order-email.handle
    description: "Send order e-mail when it is created on database"
    memorySize: 512
    runtime: nodejs16.x
    timeout: 300
    events:
      - eventBridge:
          enabled: true
          eventBus: !GetAtt MongoDbOnInserOrderEventBus.Name
          pattern:
            source:
              - prefix: aws.partner/mongodb.com

resources:
  Resources:
    MongoDbOnInserOrderEventBus:
      Type: "AWS::Events::EventBus"
      Properties:
        EventSourceName: ${self:provider.environment.EVENT_ON_INSERT_ORDER}
        Name: ${self:provider.environment.EVENT_ON_INSERT_ORDER}