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 🙏

© 2025 – Pkg Stats / Ryan Hefner

aws-wrapper

v1.8.2

Published

Trendalytics AWS module, wrapper for official aws-sdk

Readme

AWS wrapping module

This module is a wrapper for the official aws-sdk module. It incapsulates all routines, and exposes some simple straight-forward methods. Currently it wraps some methods only for S3 and SQS services. More methods and services will be added in the future.

Note: The module has been developed while working for Trendalytics.

API

After instantiating aws-wrapper, it will contain 2 objects - s3 and sqs. Below is the API for each of them.

S3

/**
 * Get S3 url based on S3 full path
 *
 * @param {String} s3Path - full S3 path, including bucket name and the path itself
 *
 * @return {String} s3Url
 */
aws.s3.getUrl(s3Path);

/**
 * Upload file to S3
 *
 * @callback uploadCallback
 * @param {Object} error
 * @param {String} s3Url
 * @param {Object} extraInfo - contains extra info, such as bucket and key
 *
 *
 * @param {String} s3Path - S3 file path, including bucket name. E.g. myBucket/path/to/folder/file.txt
 * @param {String|Object} dataSource - local file path to be uploaded, or a ReadableStream object
 * @param {uploadCallback} callback
 */
aws.s3.upload(s3Path, dataSource, callback);

/**
 * Get S3 file contents
 *
 * @callback methodCallback
 * @param {Object} error
 * @param {String} fileContents
 *
 * @param {String} s3Path - S3 file path, including bucket name. E.g. myBucket/path/to/folder/file.txt
 * @param {methodCallback} callback
*/
aws.s3.getFileContents(s3Path, callback);

SQS

/**
 * Push a message to SQS
 *
 * @callback pushCallback
 * @param {Object} error
 * @param {Object} result - contains result object: { ResponseMetadata: { <meta data> }, MD5OfMessageBody: '<hash>', MessageId: '<id> }
 *
 *
 * @param {String} queueName
 * @param {Object} msgObj
 * @param {pushCallback} callback
 */
aws.sqs.pushMessage(queueName, msgObj, callback);

/**
 * Get a message from SQS
 *
 * @callback getCallback
 * @param {Object} error
 * @param {Object} message - contains all data related to message. Most useful properties - message.Obj and message.MessageId
 *
 *
 * @param {String} queueName
 * @param {getCallback} callback
 */
aws.sqs.getMessage(queueName, callback);

/**
 * Delete a message from SQS by Receipt Handler
 *
 * @callback deleteCallback
 * @param {Object} error
 * @param {Object} result - contains metadata
 *
 *
 * @param {String} queueName
 * @param {String} receiptHandler
 * @param {deleteCallback} callback
 */
aws.sqs.deleteMessage(queueName, receiptHandler, callback);

/**
 * Purge a queue by name
 *
 * @callback methodCallback
 * @param {Object} error
 * @param {Object} result - metadata
 *
 *
 * @param {String} queueName
 * @oaram {methodCallback} callback
 */
aws.sqs.purgeQueue(queueName, callback);

Usage


var awsConfig = {
	"accessKeyId": "<access key id>",
	"secretAccessKey": "<secret access key>",
	"region": "<region>"
};

var aws = require('aws-wrapper')(awsConfig);

// Upload an Image to S3
aws.s3.upload('my-bucket', 'path/to/a/folder/filename.png', '/tmp/some-file.png', function (err, s3Url) {
	if (err) { throw err; }
	console.log('Image url is', s3Url);
});

/***  Manage SQS ***/

// Message obj to push to queue
var msgObj = {
	action: 'do-some-action',
	params: {
		param1: 'value1',
		param2: 'value2'
	}
};

// Push to SQS
aws.sqs.pushMessage('my-queue', msgObj, function (err, data) {
	if (err) { throw err; }

	// Make use of `data` object
	// ...
});

// Get a message from SQS
aws.sqs.getMessage('my-queue', function (err, data) {
	if (err) { throw err; }

	if (data && data.Obj) {
		// Make use of `data.Obj`
		// ...
	}
});

// Purge a SQS queue
aws.sqs.purgeQueue('my-queue', function (err, data) {
    if (err) { throw err; }
});