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

node-mandrill-retry

v1.0.1

Published

A node.js wrapper for MailChimp's Mandrill API.

Downloads

6

Readme

node-mandrill

node-mandrill is a node.js module designed to allow you to access MailChimp's Mandrill API with minimal overhead.

I designed node-mandrill so the only documentation you need, in addition to the Mandrill API specification, is how to install node, how to install the module, and how to make a call.

Installation

Using npm:

npm install node-mandrill

If you don't have or don't want to use npm:

cd ~/.node_modules
git clone git://github.com/jimrubenstein/node-mandrill.git 

Usage

Usage is super simple. To require the mandrill library and initialize it with your account API key:

var mandrill = require('node-mandrill')('<Your Api Key Here>');

To make a call to the API, call the mandrill function. For example:

//send an e-mail to jim rubenstein
mandrill('/messages/send', {
    message: {
        to: [{email: '[email protected]', name: 'Jim Rubenstein'}],
        from_email: '[email protected]',
        subject: "Hey, what's up?",
        text: "Hello, I sent this message using mandrill."
    }
}, function(error, response)
{
    //uh oh, there was an error
    if (error) console.log( JSON.stringify(error) );

    //everything's good, lets see what mandrill said
    else console.log(response);
});

Arguments

mandrill(string: api-endpoint, object: options, [function: callback])

mandrill(string: api-endpiont, function: callback])

Api Endpoint: The REST url for the API you want to access. By default, all requests are made requesting JSON as the response format. If you'd like to utilize a different format, you cann append .yaml, .php, or .xml to the endpoint uri. Node-mandrill will parse json responses and pass them to the callback, but the other formats will be passed back as a string.

Options: A javascript object defining the options as needed for the requested API endpoint. note: your API key is not required here, as the module will automatically append it to your request. However, you can override your configured key by passing a value for a new key, using the key index of the options object.

Callback: A function reference for a function to call upon completion of the request. It should accept 2 arguments.

error: if an error occurred (either with the HTTP request, or within the Mandrill API) the error will be passed back in this argument. If there was no error, the value of error will be null.

response: the response from Mandrill in the requested format. JSON is requested by default, and is parsed into a native javascript object upon completion of the request. If you choose to use one of the other formats (xml, yaml, php) the response will be passed back as a string to be used with your favorite parsers.

Requirements

  • A Mandrill account w/API key.
  • node.js v0.8.2+ (0.8.2 is the version I used to develop this module. I'm unsure if it will work with previous ones. If you run a previous version, and it works, let me know and I'll update this)
  • request 2.9.100+
  • underscore 1.3.3+

Running Tests

Tests are written using Jasmine, using the jasmine-node binaries. You'll need to install jasmine-node to run the tests.

Once jasmine is installed, you will need to edit the spec/mandrill.spec.js file to reflect your Mandrill API key, and an email address to receive your test e-mail on. These two settings are at the top of the file. Once they're in place, run your tests by doing:

$ ./test.sh

On your command line. If you're running windows, well, sorry. ):

Question? Problems?

If you run into problems, have questions, or whatever else you can open an issue on this repository, or tweet me @jim_rubenstein. If you'd like to submit a patch, shoot me a pull request. I'd like to keep this module simple, so if you want to add all kinds of crazy functionality - you might want to fork. When in doubt, send a pull request - the worst that can happen is that I won't merge it (: