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

aurora-mysql2-cluster

v1.0.10

Published

Managed Pool Connections for Aurora DB

Downloads

297

Readme

aurora-mysql2-cluster

Managed Pool Connections for Aurora DB.

This module will create 2 Mysql2 pools using the Amazon Aurora endpoints. Read replicas will be automatically optimized by Amazon.

Also executes plain Mysql queries through the pools.

Configuration

This module will read the enviromental variables in order to find the information regarding to the write and read endpoints for the Aurora Cluster. If the information for read is not provided, it will use the corresponding variable for write.

Enviromental Variables

Writter

  • DB_HOST
  • DB_USER
  • DB_DATABASE
  • DB_PORT
  • DB_PASS

Reader

While we can use an Aurora writter endpoint to read is not recommended. All the information not found in the enviroment will use the writter variables by default.

  • DB_HOST_DEV (RECOMMENDED)
  • DB_USER_DEV (OPTIONAL)
  • DB_DATABASE_DEV (OPTIONAL)
  • DB_PORT_DEV (OPTIONAL)
  • DB_PASS_DEV (OPTIONAL)

Creating the object

Using the enviromental variables.

const AuroraPool = require("aurora-mysql2-cluster");

let auroraPool = new AuroraPool();

Using params

const AuroraPool = require("aurora-mysql2-cluster");

let writterInfo = {
    host : "",
    user : "",
    database : "",
    port : "",
    password : ""
}

let readerInfo = {
    host : "",
    user : "",
    database : "",
    port : "",
    password : ""
}

let auroraPool = new AuroraPool(writterInfo,readerInfo);

Amazon Systems Manager Agent (SSM)

A good practice is to keep passwords encrypted and database information safe. That is why by default we can use SSM variables directly from our account. Any variable that we want to be loaded from AWS SSM just need to start with the pattern "ssm//".

For example :

let writterInfo = {
    host : "ssm//RDS_GW_HOST_WRITE",
    password : "ssm//RDS_GW_HOST_PASSWORD"
}

In this case we will load the host and the password from SSM ( Assuming you have permissions ). All passwords MUST be encrypted in SSM.

Read Query

auroraPool.read(query);

Return Mysql2 pool query result as a promise.

Write Query

auroraPool.write(query);

Return Mysql2 pool query result as a promise.