mashape-tools

Connect-style middlewares to perform security checks on your Mashape-API backend by validating HTTP-Headers and allowed Proxy-IPs. It also provides a simple service-container for Mashape-APIs

Mashape-Tools

Connect-style middlewares to perform security checks on your Mashape-API backend by validating HTTP-Headers and allowed Proxy-IPs. It also provides a simple service-container for Mashape-APIs

Install the module with: npm install mashape-tools

To use the IP-Filter download the official list of Mashape-IPs as JSON and store it within your application.

var express = require('express'),
    app = express(),
    mashape = require('mashape-tools');
 
// Enable IP-Filter 
app.use(mashape.ipFilter({
    iplist: '/path/to/iplist.json' // or an array of IPs 
}));
 
// Enable Proxy-Secret-Filter 
app.use(mashape.headerFilter({
    proxySecret: 'YourMashapeProxySecret',
    additionalHeaderChecks: [
        { name: 'x-your-header', value: 'your-header-value' }
    ]
}));
 
// Use the Service Container 
app.use(mashape.serviceContainer({
    mashapeKey: process.env.MASHAPE_KEY
}));
// ... 

In lieu of a formal styleguide, take care to maintain the existing coding style. Add tests for any new or changed functionality. Lint and test your code using Grunt.

Copyright (c) 2014 Marco Grätsch
Licensed under the MIT license.