New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

apogee

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apogee - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

13

index.js

@@ -0,6 +1,17 @@

var _ = require('lodash');
exports.configuration = {
header: 'X-API-Version'
};
exports.config = function (options) {
exports.configuration = options || {};
options = options || {};
exports.configuration = _.extend(exports.configuration, options);
};
exports.limit = function (version) {
if ('string' !== typeof(version)) {
throw new Error('Please supply a version for this route.');
}
return function (req, res, next) {

@@ -7,0 +18,0 @@ var header;

6

package.json

@@ -9,6 +9,8 @@ {

},
"version": "1.0.0",
"version": "1.0.1",
"repository": "git://github.com/originalmachine/apogee.git",
"main": "index.js",
"dependencies": {},
"dependencies": {
"lodash": "^2.4.1"
},
"devDependencies": {

@@ -15,0 +17,0 @@ "chai": "^1.9.1",

@@ -6,2 +6,12 @@ var apogee = require('../')

describe('Configuration', function () {
it('should default to the standard x-api-version header', function () {
expect(apogee.configuration.header).to.equal('X-API-Version');
});
it('should set the default version to undefined', function () {
expect(apogee.configuration.default).to.equal(undefined);
});
});
describe('API Versioning', function () {

@@ -69,2 +79,21 @@ beforeEach(function () {

});
it('should respond with 404 Not Found if no matching version is found, and no default exists', function (done) {
var app = express();
apogee.config({ header: 'x-apogee-version' });
app.route('/widgets').all(apogee.limit('v2')).get(function (req, res) {
res.json({ message: 'v2' });
});
app.route('/widgets').all(apogee.limit('v1')).get(function (req, res) {
res.json({ message: 'v1' });
});
app.use(require('errorhandler')());
request(app)
.get('/widgets')
.set('x-apogee-version', 'v3')
.expect(404, done);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc