flask-router-plus
Version:
Flask-inspired routing system for node and connect. Nice if you just need a routing system without depending on connect, or need routing middleware without all features provided by express.
42 lines (40 loc) • 1.07 kB
JavaScript
// Generated by CoffeeScript 1.6.3
(function() {
exports["arguments"] = function(code, headers, data) {
var ans, ctype, nenv;
if (data == null) {
data = headers;
headers = {};
}
if ((data == null) && typeof code !== 'number') {
data = code;
code = 200;
}
if (typeof data === 'string') {
ctype = 'text/html; charset=utf-8';
} else if (data instanceof Error) {
code = data.code || 500;
ctype = 'application/json';
ans = {
message: data.message
};
nenv = process.env['NODE_ENV'];
if (nenv === 'development' || nenv === 'test') {
ans.stack = data.stack;
ans.stackPlus = new Error().stack;
}
data = JSON.stringify(ans);
} else if ((data != null) && !(data instanceof Buffer)) {
ctype = 'application/json';
data = JSON.stringify(data);
}
if (ctype && !headers['content-type']) {
headers['content-type'] = ctype;
}
return {
code: code,
headers: headers,
data: data
};
};
}).call(this);