Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

echoecho

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

echoecho - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

53

lib/scheme.js

@@ -15,2 +15,7 @@ /*

};
var CONTENT_TYPE = {
js: 'application/javascript',
css: 'text/css',
json: 'application/json'
};

@@ -29,2 +34,17 @@ var RE_DELAY_RANGE = /(\d+)-(\d+)/;

function done(req, res, code, headers, body) {
var query = parse(req.url).query,
parsed = qs.parse(query),
type = parsed.type;
if (CONTENT_TYPE[type]) {
headers = mix({
'Content-Type': CONTENT_TYPE[type]
}, headers);
}
res.writeHead(code, headers);
res.end(body);
}
var rand = exports.rand = function (min, max) {

@@ -49,13 +69,13 @@ return Math.random() * (max - min) + min;

exports.get = function (req, res, body) {
var code = ((req.method === 'GET' || req.method === 'HEAD' || req.method === 'OPTIONS') ? 200 : 403);
var code = ((req.method === 'GET' || req.method === 'HEAD' || req.method === 'OPTIONS') ? 200 : 403),
content = body || parse(req.url).query || '';
res.writeHead(code, headers);
res.end(body || parse(req.url).query || '');
done(req, res, code, headers, content);
};
exports['delete'] = function (req, res, body) {
var code = ((req.method === 'DELETE') ? 200 : 403);
var code = ((req.method === 'DELETE') ? 200 : 403),
content = body || parse(req.url).query || '';
res.writeHead(code, headers);
res.end(body || parse(req.url).query || '');
done(req, res, code, headers, content);
};

@@ -85,4 +105,3 @@

res.writeHead(code, headers);
res.end(body);
done(req, res, code, headers, body);
}

@@ -143,4 +162,4 @@

} else {
res.writeHead(200, headers);
res.end('waited for ' + seconds + ' seconds');
done(req, res, 200, headers, 'waited for '
+ seconds + ' seconds');
}

@@ -168,6 +187,5 @@ }, seconds * 1000);

res.writeHead(200, mix({
'Content-Type': 'application/json'
}, headers));
res.end(json);
done(req, res, 200, mix({
'Content-Type': CONTENT_TYPE.json
}, headers), json);
};

@@ -217,6 +235,5 @@

res.writeHead(code, mix({
'Content-Type': 'application/json'
}, headers));
res.end(json);
done(req, res, code, mix({
'Content-Type': CONTENT_TYPE.json
}, headers), json);
};

@@ -5,3 +5,3 @@ {

"author": "Dav Glass <davglass@gmail.com>",
"version": "0.1.6",
"version": "0.1.7",
"devDependencies": {

@@ -8,0 +8,0 @@ "vows": "*",

@@ -905,3 +905,35 @@ var vows = require('vows'),

// -- `type` query parameter tests --------------------------------------------
function assertContentType(route, method) {
var path = '/foo/bar/baz/echo/' + route + '?type=css';
context = {
topic: function() {
fetch({
method: method,
path: path
}, this.callback);
}
};
context[route + ' route should respond with specified content type'] = function (res) {
assert.equal(res.headers['content-type'], 'text/css');
}
return context;
}
tests['should be loaded']
['and should load paths']
['and should respond with specified content type'] = {};
testRoutes.forEach(function (route) {
tests['should be loaded']
['and should load paths']
['and should respond with specified content type']
['for route ' + route.name]
= assertContentType(route.name, route.method);
});
vows.describe('echoecho').addBatch(tests).export(module);
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