Skip to content

Commit

Permalink
Changing undefined to void 0, updating server
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed May 28, 2017
1 parent 5893200 commit d1d7ed0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ function factory (arg) {
process.exit(1);
}

if (config.root === undefined) {
if (config.root === void 0) {
config.root = root;
}

if (config.hosts === undefined) {
if (config.hosts === void 0) {
hosts[hostname] = "www";
config.hosts = hosts;
}

if (config.default === undefined) {
if (config.default === void 0) {
config.default = hostname;
}

if (config.routes.get === undefined) {
if (config.routes.get === void 0) {
config.routes.get = {};
}

Expand Down
10 changes: 5 additions & 5 deletions lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ function decorate (req, res, next) {
req.protect = false;
req.protectAsync = false;
req.unprotect = false;
res.error = (status, body) => obj.respond(req, res, body !== undefined ? body instanceof Error ? body : new Error(body) : new Error(http.STATUS_CODES[status]), status);
res.redirect = (uri, perm = true) => obj.redirect(req, res, uri, undefined, perm);
res.error = (status, body) => obj.respond(req, res, body !== void 0 ? body instanceof Error ? body : new Error(body) : new Error(http.STATUS_CODES[status]), status);
res.redirect = (uri, perm = true) => obj.redirect(req, res, uri, void 0, perm);
res.respond = (body, status, headers) => obj.respond(req, res, body, status, headers);
res.send = (body, status, headers) => obj.respond(req, res, body, status, headers);
next();
Expand Down Expand Up @@ -47,7 +47,7 @@ function guard (req, res, next) {
}

function parse (req, res, next) {
if (regex.body.test(req.method) && req.body !== undefined) {
if (regex.body.test(req.method) && req.body !== void 0) {
let type = req.headers["content-type"];

if (regex.encode_form.test(type)) {
Expand Down Expand Up @@ -102,7 +102,7 @@ function keymaster (req, res, next) {
return void 0;
});

if (result !== undefined) {
if (result !== void 0) {
if (typeof result === "function") {
result.call(obj, req, res);
} else {
Expand Down Expand Up @@ -160,7 +160,7 @@ function zuul (req, res, next) {
req.protectAsync = false;

rate(req, res, e => {
if (e !== undefined) {
if (e !== void 0) {
next(e);
} else if (protectd) {
next();
Expand Down
12 changes: 6 additions & 6 deletions lib/tenso.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Tenso {
seconds = parseInt(new Date().getTime() / 1000, 10),
limit, remaining, reset, state;

if (this.rates[id] === undefined) {
if (this.rates[id] === void 0) {
this.rates[id] = {
limit: config.limit,
remaining: config.limit,
Expand Down Expand Up @@ -98,7 +98,7 @@ class Tenso {
renderer = renderers.get(format);
headers["content-type"] = format;

return renderer(arg, req, headers, format === "text/html" ? this.server.config.template : undefined);
return renderer(arg, req, headers, format === "text/html" ? this.server.config.template : void 0);
}

renderer (mimetype, fn) {
Expand All @@ -119,12 +119,12 @@ class Tenso {
}

// Decorating early for renderers
if (ref[0].allow === undefined) {
if (ref[0].allow === void 0) {
ref[0].allow = req.allow;
}

if (!regex.get_rewrite.test(req.method)) {
if (ref[0]["cache-control"] === undefined && this.server.config.headers["cache-control"]) {
if (ref[0]["cache-control"] === void 0 && this.server.config.headers["cache-control"]) {
ref[0]["cache-control"] = utility.clone(this.server.config.headers["cache-control"]) || "public";
}

Expand All @@ -133,7 +133,7 @@ class Tenso {
ref[0]["cache-control"] = "private" + (ref[0]["cache-control"].length > 0 ? ", " : "") + (ref[0]["cache-control"] || "");
}

if (!regex.modify.test(req.method) && regex.modify.test(req.allow) && this.server.config.security.csrf && res.locals[this.server.config.security.key] !== undefined) {
if (!regex.modify.test(req.method) && regex.modify.test(req.allow) && this.server.config.security.csrf && res.locals[this.server.config.security.key] !== void 0) {
ref[0][this.server.config.security.key] = res.locals[this.server.config.security.key];
}

Expand Down Expand Up @@ -193,7 +193,7 @@ class Tenso {
let output;

if (typeof req.parsed.search === "string" && hasOrderBy.test(req.parsed.search) && Array.isArray(arg)) {
if (!(/boolean|number|string|undefined/).test(typeof arg[0]) && arg[0] !== null) {
if (!(/boolean|number|string|void 0/).test(typeof arg[0]) && arg[0] !== null) {
output = keysort(utility.clone(arg), req.parsed.search.replace("?", "").split("&").filter(i => orderBy.test(i)).reduce((a, b) => {
a.push(b.replace(orderBy, ""));

Expand Down
2 changes: 1 addition & 1 deletion lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ function hypermedia (server, req, rep, headers) {
parent.pop();
}

rep.data = marshal(rep.data, undefined, retsu.last(parent));
rep.data = marshal(rep.data, void 0, retsu.last(parent));
}

if (rep.links.length > 0) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tenso",
"description": "Tensō is an elastic REST API gateway for node.js",
"version": "4.5.19",
"version": "4.5.20",
"homepage": "http://avoidwork.github.io/tenso",
"author": "Jason Mulligan <[email protected]>",
"repository": {
Expand Down Expand Up @@ -45,7 +45,7 @@
"tiny-merge": "~1.0.0",
"tiny-uuid4": "~1.0.1",
"tiny-xml": "~1.0.6",
"turtle.io": "~7.5.22",
"turtle.io": "~7.5.23",
"uws": "~0.14.5",
"yamljs": "~0.2.10"
},
Expand Down

0 comments on commit d1d7ed0

Please sign in to comment.