MaxCDN API for Node.js
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
test
.gitignore
.travis.yml
BENCHMARKS.md
CHANGELOG.md
LICENSE
Makefile
README.md
index.js
package.json

README.md

node-maxcdn

MaxCDN API for Node.js

Build Status   Dependancy Status   NPM Version   <iframe src="http://jmervine.github.io/npm-downloads-badge/badge.html?module=maxcdn&name=false" allowtransparency="true" frameborder="0" scrolling="0" width="125" height="20" style="vertical-align: bottom"></iframe>

Note: Unit tests have been run agaist latest 4.x and 5.x versions of Node.js.

Install

$ npm install maxcdn

Usage

Initialize

var maxcdn = require('maxcdn').create('COMPANY_ALIAS', 'CONSUMER_KEY', 'CONSUMER_SECRET');

maxcdn.get

maxcdn.get('reports/stats.json/daily', function(err, results) {
    if (err) {
        console.trace(err);
        return;
    }
    console.dir(results);
});

maxcdn.put

var updates = {
    street1: '555 Some St.',
    street2: 'Suite #1'
};
maxcdn.put('account.json/address', updates, function(err, results) {
    if (err) {
        console.trace(err);
        return;
    }
    console.dir(results);
});

maxcdn.post

maxcdn.post('zones/pull.json', { name: 'testname', url: 'http://www.example.com' }, function(err, results) {
    if (err) {
        console.trace(err);
        return;
    }
    console.dir(results);
});

maxcdn.del

Has alias of maxcdn.delete.

var zoneId = '121212';

// full cache
maxcdn.del('zones/pull.json/'+zoneId+'/cache', function(err, results) {
    if (err) {
        console.trace(err);
        return;
    }
    if (results.code === 200) {
        console.log('SUCCESS!');
    }
});

// specific files
var files = { files: [ '/master.css', '/another.css' ] };
maxcdn.del('zones/pull.json/'+zoneId+'/cache', files, function(err, results) {
    if (err) {
        console.trace(err);
        return;
    }
    if (results[0].code === 200) {
        console.log('SUCCESS: %s', files.files[0]);
    }
    if (results[1].code === 200) {
        console.log('SUCCESS: %s', files.files[1]);
    }
});

Running Tests

Unit Tests

$ make setup test

Integration Tests

$ ALIAS=alias KEY=key SECRET=secret make setup int

Troubleshooting:

Ensure that you ALIAS, KEY and SECRET values are correct and that you're running integration on a host with a whitelisted IP address.