Socket
Socket
Sign inDemoInstall

caddis

Package Overview
Dependencies
167
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.0 to 0.4.1

examples/calabash/features/caddis_example.feature

12

HISTORY.md

@@ -0,1 +1,13 @@

0.4.0 / 2014-03-03
==================
* 0.4.0
* better change logs
* lightweight body parser to accept param string and JSON.
* perhaps some support for request param parse on body.
* support for port option!
* proper temrination on regex matching for uri on add route.
* update to forever runner on caddis to preseved session-only logging at HOME for developer debugging purposes.
* light logging in caddis server.
* experimental removal of express to allow custom ports.
* up of node version dependency.

@@ -2,0 +14,0 @@ 0.3.6 / 2014-02-26

42

lib/caddis/server.js

@@ -7,5 +7,7 @@ 'use strict';

var routeSupport = ['get', 'post', 'put', 'delete'];
var callHistory = [];
var ROOT_ENDPOINT = /^\/$/i;
var API_ENDPOINT = /\/api/i;
var CALL_HISTORY_ENDPOINT = /\/_call_requests/i;
var COLON_TOKEN = /(:\w+)/gi;

@@ -22,2 +24,6 @@ var COLON_REPLACE = '(' + '\\' + 'w+)';

var requestIsHistory = function(req) {
return req.length === 0 || req.url.match(CALL_HISTORY_ENDPOINT);
};
var requestIsAPIRoute = function(req) {

@@ -57,2 +63,11 @@ return req.method.toLowerCase() === 'post' && req.url.match(API_ENDPOINT);

var addToCallHistory = function(request, response) {
var callEntry = {
request: (typeof request === 'string') ? JSON.parse(request) : request,
response: (typeof response === 'string') ? JSON.parse(response) : response
};
callHistory.push(callEntry);
print('Added to history: ' + JSON.stringify(callEntry, null, 2));
};
var findRouteFromRequest = function(req) {

@@ -131,2 +146,14 @@ var routeList = routeMap[req.method.toLowerCase()];

}
else if(requestIsHistory(request)) {
request.on('end', function() {
body = JSON.stringify(callHistory) + '\n';
response.writeHead(200, {
'Content-Type': 'application/json',
'Content-Length': body.length
});
response.end(body);
print('Call history request.');
print('Response: ' + body);
});
}
else if(requestIsAPIRoute(request)) {

@@ -160,7 +187,14 @@ request.on('end', function() {

respond = function() {
response.writeHead(!isNaN(statusCode) ? statusCode : 200, {
'Content-Type': 'application/json',
'Content-Length': body.length
});
response.writeHead(!isNaN(statusCode) ? statusCode : 200, {
'Content-Type': 'application/json',
'Content-Length': body.length
});
response.end(body);
addToCallHistory({
method: request.method,
url: request.url,
statusCode: request.statusCode ? request.statusCode : 200,
body: data && data.length > 0 ? data : null
}, body);
};

@@ -167,0 +201,0 @@ print('Stored route found.');

2

package.json
{
"name": "caddis",
"version": "0.4.0",
"version": "0.4.1",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

@@ -5,2 +5,4 @@ Caddis

![caddis npm](https://nodei.co/npm/caddis.png)
Installation

@@ -7,0 +9,0 @@ ---

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc