GithubHelp home page GithubHelp logo

node-maxcdn's Introduction

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>

Install

$ npm install maxcdn

Usage

Initialize

var MaxCDN = require('maxcdn');
var maxcdn = new MaxCDN('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.delete

var zoneId = '121212';

// full cache
maxcdn.delete('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.delete('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]);
    }
});

Not Implemented

  • post - fails with error, getting the same error with Ruby gem.

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.

node-maxcdn's People

Contributors

jdorfman avatar jmervine avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.