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

@voodoo.io/aws-utils

v3.0.3

Published

AWS utils methods - using homemade retry system

Downloads

1,208

Readme

aws-utils

Purpose

Simple wrapper around aws-sdk to make it easier to use.

Compatibility

/!\ This module use async/await syntax, this is why you must have node 7.6+.

Supported and tested : >= 12.x

| Version | Supported | Tested | | ------------- |:-------------:|:--------------:| | 16.x | yes | yes | | 14.x | yes | yes | | 12.x | yes | yes |

BREAKING CHANGES since version 2.0

Now dynamo tools returns an object and not directly an array of items.

{
    Items:[ { ....} , { ... } ],
    LastEvaluatedKey: {....}
}

Installation

$ npm install @voodoo.io/aws-utils --save

Usage

Dynamo tools

Configure dynamo tools

const awsUtils = require('@voodoo.io/aws-utils').dynamo;

const aws = require('aws-sdk');
aws.config.update({region: 'eu-west-1'});
const dynamoCli = new aws.DynamoDB.DocumentClient();
const dynamoTools = new awsUtils(dynamoCli)

Query

const res = await dynamoTools.queryHashKey('myTable', 'key', 'value');
const res = await dynamoTools.query('myTable', { 'conditions': [{'key': 'value', 'operator': 'value', 'value': [] /** or ''**/}]})

Scan

const res = await dynamoTools.scan('myTable');

Put item

const res = await dynamoTools.putItem('myTable', {'key': 'value'});

Put items

const res = await dynamoTools.putItems('myTable', [{'key': 'value'}]);

Put transactional items

const res = await dynamoTools.putTransactionItems([{'key': 'value'}]);

Update item

await dynamoTools.update('myTable', {'key': {'primaryKey': 'value', 'sortKey': 'value'},'add': {['column1']: 'value'}, 'set': {'column2': 'value'}});

delete item

const res = await dynamoTools.deleteItem('myTable', {'key': 'value'});

queryHashKey(dynamoTable, hashKeyName, hashKeyValue, [exclusiveStartKey], [limit])

  • dynamoTable : table's name
  • hashKeyName : hashkey's name
  • hashKeyValue : hashkey's value
  • exclusiveStartKey : (optional) start search at a specific key
  • limit : (optional) don't return more items than the limit

query(dynamoTable, customParams)

  • dynamoTable : table's name
  • customParams : object with the conditions of the query

putItem(dynamoTable, item)

  • dynamoTable : table's name
  • item : item to insert

putItems(dynamoTable, items)

  • dynamoTable : table's name
  • item : an array of items to insert

scan(dynamoTable, [hashKeyName], [hashKeyValue], [exclusiveStartKey], [limit])

  • dynamoTable : table's name
  • hashKeyName : (optional) hashkey's name
  • hashKeyValue : (optional) hashkey's value
  • exclusiveStartKey : (optional) start search at a specific key
  • limit : (optional) don't return more items than the limit

If no hashkey is provided it returns the full table.

updateItem(dynamoTable, params)

  • dynamoTable : table's name
  • params : parameters with columns to update

deleteItem(dynamoTable, key)

  • dynamoTable : table's name
  • key : hashkey to delete

Secret Manager tools

Configure secret manager tools

const awsUtils = require('@voodoo.io/aws-utils').secretManager;

const aws = require('aws-sdk');
aws.config.update({region: 'eu-west-1'});
const cli = new aws.SecretsManager({});
const secretManagerTools = new awsUtils(cli);

getSecretValue

const res = await secretManagerTools.getSecretValue('secret');

getSecretValue(secret)

  • secret : secret's id

S3 tools

Configure S3 tools

const awsUtils = require('@voodoo.io/aws-utils').s3;

const aws = require('aws-sdk');
aws.config.update({region: 'eu-west-1'});
const cli = new aws.S3();
const s3Tools = new awsUtils(cli);

getObject

const res = await s3Tools.getObject('bucket', 'key');

getObject(bucket, key)

  • bucket : bucket's name
  • key : path to the ressource (/path/file.json)

putJsonObject

const res = await s3Tools.putJsonObject('bucket', 'key', {"key": "value"});

putJsonObject(bucket, key, item)

  • bucket : bucket's name
  • key : path to the ressource (/path/file.json)
  • item : json object to save on S3

emptyS3Directory

const res = await s3Tools.emptyS3Directory('bucket', 'dir/');

emptyS3Directory(bucket, dir)

  • bucket : bucket's name
  • dir : directory to remove

Test

$ npm test

Coverage report can be found in coverage/.