diff --git a/.eslintrc b/.eslintrc
deleted file mode 100644
index 56b7ef8..0000000
--- a/.eslintrc
+++ /dev/null
@@ -1,268 +0,0 @@
----
- env:
- node: true
-
- globals:
- debugger: false
-
- rules:
-# Comment headers correspond to ESLint rule breakdowns in their docs.
-# 0 -> disabled, 1 -> warning, 2 -> error
-##### Possible Errors
- comma-dangle:
- - 2
- - "never"
- no-cond-assign:
- - 2
- - "always"
- no-console: 1
- no-constant-condition: 2
- no-control-regex: 2
- no-debugger: 1
- no-dupe-args: 2
- no-dupe-keys: 2
- no-duplicate-case: 2
- no-empty-character-class: 2
- no-empty: 2
- no-ex-assign: 2
- no-extra-boolean-cast: 2
- no-extra-parens:
- - 2
- - "all"
- no-extra-semi: 2
- no-func-assign: 2
- no-inner-declarations:
- - 2
- - "both"
- no-invalid-regexp: 2
- no-irregular-whitespace: 2
- no-negated-in-lhs: 2
- no-obj-calls: 2
- no-regex-spaces: 2
- no-sparse-arrays: 2
- no-unreachable: 2
- use-isnan: 2
- # valid-jsdoc: 2
- valid-typeof: 2
- no-unexpected-multiline: 2
-
-##### Best Practices
- accessor-pairs: 2
- block-scoped-var: 2
- complexity: 1
- consistent-return: 2
- curly:
- - 2
- - "all"
- default-case: 2
- dot-notation:
- - 2
- - allowKeywords: true
- dot-location:
- - 2
- - "property"
- eqeqeq:
- - 2
- - "allow-null"
- guard-for-in: 2
- no-alert: 1
- no-caller: 2
- no-div-regex: 2
- no-else-return: 2
- no-empty-label: 2
- no-eq-null: 0
- no-eval: 2
- no-extend-native: 2
- no-extra-bind: 2
- no-fallthrough: 2
- no-floating-decimal: 2
- no-implicit-coercion:
- - 2
- - string: true
- number: true
- boolean: true
- no-implied-eval: 2
- no-invalid-this: 2
- no-iterator: 2
- no-labels: 2
- no-lone-blocks: 2
- no-loop-func: 2
- no-multi-spaces: 2
- no-multi-str: 2
- no-native-reassign: 2
- no-new-func: 2
- no-new-wrappers: 2
- no-new: 2
- no-octal-escape: 2
- no-octal: 2
- no-param-reassign: 0
- no-process-env: 0
- no-proto: 2
- no-redeclare: 2
- no-return-assign: 2
- no-script-url: 2
- no-self-compare: 2
- no-sequences: 2
- no-throw-literal: 2
- no-unused-expressions: 2
- no-useless-call: 2
- no-void: 2
- no-warning-comments:
- - 1
- - terms:
- - "todo"
- - "fixme"
- location: "anywhere"
- no-with: 2
- radix: 2
- vars-on-top: 2
- wrap-iife:
- - 2
- - "inside"
- yoda:
- - 2
- - "never"
-
-##### Strict Mode
- strict:
- - 2
- - "global"
-
-##### Variables
- init-declarations: 0
- no-catch-shadow: 2
- no-delete-var: 2
- no-label-var: 2
- no-shadow-restricted-names: 2
- no-shadow: 2
- no-undef-init: 2
- no-undef: 2
- no-undefined: 2
- no-unused-vars: 2
- no-use-before-define:
- - 2
- - "nofunc"
-
-##### Node.js (ignored)
-
-##### Stylistic Issues
- array-bracket-spacing:
- - 2
- - "never"
- brace-style:
- - 2
- - "1tbs"
- - allowSingleLine: true
- camelcase: 2
- comma-spacing:
- - 2
- - before: false
- after: true
- comma-style:
- - 2
- - "last"
- computed-property-spacing:
- - 2
- - "never"
- consistent-this:
- - 2
- - "self"
- eol-last: 2
- func-names: 0
- func-style:
- - 2
- - "declaration"
- id-length: 0
- id-match: 0
- indent:
- - 2
- - 2
- - SwitchCase: 1
- key-spacing:
- - 2
- - beforeColon: false
- afterColon: true
- lines-around-comment: 0
- linebreak-style:
- - 2
- - "unix"
- max-nested-callbacks: 0
- new-cap:
- - 2
- - newIsCap: true
- capIsNew: true
- new-parens: 2
- newline-after-var: 0
- no-array-constructor: 2
- no-continue: 0
- no-inline-comments: 0
- no-lonely-if: 2
- no-mixed-spaces-and-tabs: 2
- no-multiple-empty-lines:
- - 2
- - max: 1
- no-nested-ternary: 2
- no-new-object: 2
- no-spaced-func: 2
- no-ternary: 0
- no-trailing-spaces: 2
- no-underscore-dangle: 0
- no-unneeded-ternary: 2
- object-curly-spacing:
- - 2
- - "never"
- one-var:
- - 2
- - uninitialized: "always"
- initialized: "never"
- operator-assignment:
- - 2
- - "always"
- operator-linebreak:
- - 2
- - "after"
- - overrides:
- "?": "before"
- ":": "before"
- padded-blocks:
- - 2
- - "never"
- quote-props:
- - 2
- - "as-needed"
- quotes:
- - 2
- - "single"
- - "avoid-escape"
- semi-spacing:
- - 2
- - before: false
- after: true
-#
- semi:
- - 2
- - "always"
- sort-vars: 0
- space-after-keywords:
- - 2
- - "always"
- space-before-blocks:
- - 2
- - "always"
- space-before-function-paren:
- - 2
- - anonymous: "always"
- named: "never"
- space-in-parens:
- - 2
- - "never"
- space-infix-ops: 2
- space-return-throw-case: 2
- space-unary-ops:
- - 2
- - words: true
- nonwords: false
- spaced-comment:
- - 2
- - "always"
- wrap-regex: 0
diff --git a/package.json b/package.json
index 131b7ac..5df96ee 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,7 @@
"webroot"
],
"scripts": {
- "lint": "eslint src test",
+ "lint": "semistandard",
"test": "npm run lint && mocha --recursive test --reporter dot",
"start": "bin/stubby"
},
@@ -56,12 +56,23 @@
},
"devDependencies": {
"buffer-equal": "^1.0.0",
- "eslint": "^1.2.1",
"mocha": "^3.1.2",
+ "semistandard": "^9.2.1",
"sinon": "^1.17.6"
},
"license": "Apache-2.0",
"engine": {
"node": ">=0.10"
+ },
+ "semistandard": {
+ "ignore": [
+ "webroot/js/external"
+ ],
+ "globals": [
+ "it",
+ "describe",
+ "beforeEach",
+ "afterEach"
+ ]
}
}
diff --git a/src/console/args.js b/src/console/args.js
index 6f3dd58..a456d9a 100644
--- a/src/console/args.js
+++ b/src/console/args.js
@@ -4,7 +4,7 @@ var pp = require('./prettyprint');
var UNARY_FLAGS = /^-[a-zA-Z]+$/;
var ANY_FLAG = /^-.+$/;
-function findOption(option, argv) {
+function findOption (option, argv) {
var argIndex = -1;
if (option.flag != null) {
@@ -18,7 +18,7 @@ function findOption(option, argv) {
return argIndex;
}
-function indexOfFlag(option, argv) {
+function indexOfFlag (option, argv) {
var index = -1;
argv.forEach(function (flag) {
@@ -30,11 +30,11 @@ function indexOfFlag(option, argv) {
return index;
}
-function optionSkipped(index, argv) {
+function optionSkipped (index, argv) {
return ANY_FLAG.test(argv[index + 1]);
}
-function unaryCheck(option, argv) {
+function unaryCheck (option, argv) {
if (option.name != null && argv.indexOf('--' + option.name) !== -1) {
return true;
}
@@ -44,7 +44,7 @@ function unaryCheck(option, argv) {
return indexOfFlag(option, argv) !== -1;
}
-function pullPassedValue(option, argv) {
+function pullPassedValue (option, argv) {
var argIndex;
if (option.param == null) { return unaryCheck(option, argv); }
@@ -58,7 +58,7 @@ function pullPassedValue(option, argv) {
return option.default;
}
-function parse(options, argv) {
+function parse (options, argv) {
var args = {};
if (argv == null) { argv = process.argv; }
@@ -71,7 +71,7 @@ function parse(options, argv) {
return args;
}
-function helpText(options, programName) {
+function helpText (options, programName) {
var inlineList = [];
var firstColumn = {};
var helpLines = [];
diff --git a/src/console/cli.js b/src/console/cli.js
index aa85405..8028e23 100644
--- a/src/console/cli.js
+++ b/src/console/cli.js
@@ -16,7 +16,7 @@ var options = [{
name: 'cert',
flag: 'c',
param: 'file',
- default: __dirname + '/../../tls/cert.pem',
+ default: path.resolve(__dirname, '../../tls/cert.pem'),
description: 'Certificate file. Use with --key.'
}, {
name: 'data',
@@ -32,7 +32,7 @@ var options = [{
name: 'key',
flag: 'k',
param: 'file',
- default: __dirname + '/../../tls/key.pem',
+ default: path.resolve(__dirname, '../../tls/key.pem'),
description: 'Private key file. Use with --cert.'
}, {
name: 'location',
@@ -71,7 +71,7 @@ var options = [{
description: 'Auto-reload data file when edits are made.'
}];
-function help(go) {
+function help (go) {
if (go == null) { go = false; }
if (!go) { return; }
@@ -79,7 +79,7 @@ function help(go) {
process.exit();
}
-function version(go) {
+function version (go) {
var ver = (require('../../package.json')).version;
if (!go) { return ver; }
@@ -88,7 +88,7 @@ function version(go) {
process.exit();
}
-function data(filename) {
+function data (filename) {
var filedata;
if (filename === null) { return []; }
@@ -109,11 +109,11 @@ function data(filename) {
}
}
-function key(file) { return readFile('k', 'key', file, 'pem'); }
-function cert(file) { return readFile('c', 'cert', file, 'pem'); }
-function pfx(file) { return readFile('p', 'pfx', file, 'pfx'); }
+function key (file) { return readFile('k', 'key', file, 'pem'); }
+function cert (file) { return readFile('c', 'cert', file, 'pem'); }
+function pfx (file) { return readFile('p', 'pfx', file, 'pfx'); }
-function readFile(flag, option, filename, type) {
+function readFile (flag, option, filename, type) {
var filedata, extension;
if (filename === null) { return null; }
@@ -131,7 +131,7 @@ function readFile(flag, option, filename, type) {
return filedata.trim();
}
-function getArgs(argv) {
+function getArgs (argv) {
var self = this; // eslint-disable-line
var params;
diff --git a/src/console/colorsafe.js b/src/console/colorsafe.js
index c53d9fe..e0add38 100644
--- a/src/console/colorsafe.js
+++ b/src/console/colorsafe.js
@@ -1,7 +1,7 @@
'use strict';
/* eslint-disable no-console */
-function stripper(args) {
+function stripper (args) {
var key, value;
for (key in args) {
if (!args.hasOwnProperty(key)) { continue; }
@@ -12,7 +12,7 @@ function stripper(args) {
return args;
}
-function colorsafe(console) {
+function colorsafe (console) {
if (process.stdout.isTTY) { return true; }
console.raw = {};
diff --git a/src/console/prettyprint.js b/src/console/prettyprint.js
index 8c7daf1..3f5ff9d 100644
--- a/src/console/prettyprint.js
+++ b/src/console/prettyprint.js
@@ -2,12 +2,12 @@
var times = require('../prototype/times'); // eslint-disable-line
-function spacing(length) {
+function spacing (length) {
if (length == null) { length = 0; }
return ' '.times(length);
}
-function wrap(tokens, continuation, columns) {
+function wrap (tokens, continuation, columns) {
var wrapped, gutter;
if (continuation == null) { continuation = 0; }
diff --git a/src/console/watch.js b/src/console/watch.js
index 7bd4789..7ffd311 100644
--- a/src/console/watch.js
+++ b/src/console/watch.js
@@ -10,7 +10,7 @@ var interval = 3000;
var intervalId = null;
var watching = false;
-function Watcher(endpoints, filename) {
+function Watcher (endpoints, filename) {
var shasum;
this.endpoints = endpoints;
diff --git a/src/lib/clone.js b/src/lib/clone.js
index 141441f..f0522da 100644
--- a/src/lib/clone.js
+++ b/src/lib/clone.js
@@ -1,5 +1,5 @@
'use strict';
-module.exports = function clone(x) {
+module.exports = function clone (x) {
return JSON.parse(JSON.stringify(x));
};
diff --git a/src/main.js b/src/main.js
index d2b3ca0..a946a67 100644
--- a/src/main.js
+++ b/src/main.js
@@ -12,14 +12,14 @@ var https = require('https');
var contract = require('./models/contract');
var couldNotSave = "The supplied endpoint data couldn't be saved";
-function noop() {}
+function noop () {}
-function onListening(portal, port, protocol, location) {
+function onListening (portal, port, protocol, location) {
if (protocol == null) { protocol = 'http'; }
out.status(portal + ' portal running at ' + protocol + '://' + location + ':' + port);
}
-function onError(err, port, location) {
+function onError (err, port, location) {
var msg;
switch (err.code) {
@@ -40,11 +40,11 @@ function onError(err, port, location) {
process.exit();
}
-function onEndpointLoaded(err, endpoint) {
+function onEndpointLoaded (_, endpoint) {
out.notice('Loaded: ' + endpoint.request.method + ' ' + endpoint.request.url);
}
-function setupStartOptions(options, callback) {
+function setupStartOptions (options, callback) {
var defaults, key;
options = options == null ? {} : options;
@@ -68,7 +68,7 @@ function setupStartOptions(options, callback) {
return [options, callback];
}
-function createHttpsOptions(options) {
+function createHttpsOptions (options) {
var httpsOptions = options._httpsOptions || {};
if (options.key && options.cert) {
@@ -81,7 +81,7 @@ function createHttpsOptions(options) {
return httpsOptions;
}
-function Stubby() {
+function Stubby () {
this.endpoints = new Endpoints();
this.stubsPortal = null;
this.tlsPortal = null;
diff --git a/src/models/contract.js b/src/models/contract.js
index 1dab42f..32f6f0e 100644
--- a/src/models/contract.js
+++ b/src/models/contract.js
@@ -117,7 +117,7 @@ var request = {
}
};
-function contract(endpoint) {
+function contract (endpoint) {
var results, property;
var errors = [];
diff --git a/src/models/endpoint.js b/src/models/endpoint.js
index fa2c047..01a7c44 100644
--- a/src/models/endpoint.js
+++ b/src/models/endpoint.js
@@ -7,7 +7,7 @@ var url = require('url');
var q = require('querystring');
var out = require('../console/out');
-function Endpoint(endpoint, datadir) {
+function Endpoint (endpoint, datadir) {
if (endpoint == null) { endpoint = {}; }
if (datadir == null) { datadir = process.cwd(); }
@@ -61,7 +61,7 @@ Endpoint.prototype.matches = function (request) {
return matches;
};
-function record(me, urlToRecord) {
+function record (me, urlToRecord) {
var recorder;
var recording = {};
var parsed = url.parse(urlToRecord);
@@ -103,11 +103,11 @@ function record(me, urlToRecord) {
return recording;
}
-function normalizeEOL(string) {
+function normalizeEOL (string) {
return string.replace(/\r\n/g, '\n').replace(/\s*$/, '');
}
-function purifyRequest(incoming) {
+function purifyRequest (incoming) {
var outgoing;
if (incoming == null) { incoming = {}; }
@@ -130,7 +130,7 @@ function purifyRequest(incoming) {
return outgoing;
}
-function purifyResponse(me, incoming) {
+function purifyResponse (me, incoming) {
var outgoing = [];
if (incoming == null) { incoming = []; }
@@ -154,7 +154,7 @@ function purifyResponse(me, incoming) {
return outgoing;
}
-function purifyHeaders(incoming) {
+function purifyHeaders (incoming) {
var prop;
var outgoing = {};
@@ -167,7 +167,7 @@ function purifyHeaders(incoming) {
return outgoing;
}
-function purifyAuthorization(headers) {
+function purifyAuthorization (headers) {
var auth, userpass;
if (headers == null || headers.authorization == null) { return headers; }
@@ -182,7 +182,7 @@ function purifyAuthorization(headers) {
return headers;
}
-function purifyBody(body) {
+function purifyBody (body) {
if (body == null) { body = ''; }
if (typeof body === 'object') {
@@ -192,7 +192,7 @@ function purifyBody(body) {
return body;
}
-function pruneUndefined(incoming) {
+function pruneUndefined (incoming) {
var key, value;
var outgoing = {};
@@ -206,7 +206,7 @@ function pruneUndefined(incoming) {
return outgoing;
}
-function compareHashMaps(configured, incoming) {
+function compareHashMaps (configured, incoming) {
var key;
var headers = {};
if (configured == null) { configured = {}; }
@@ -221,7 +221,7 @@ function compareHashMaps(configured, incoming) {
return headers;
}
-function compareObjects(configured, incoming) {
+function compareObjects (configured, incoming) {
var key;
for (key in configured) {
@@ -235,7 +235,7 @@ function compareObjects(configured, incoming) {
return true;
}
-function matchRegex(compileMe, testMe) {
+function matchRegex (compileMe, testMe) {
if (testMe == null) { testMe = ''; }
return String(testMe).match(RegExp(compileMe, 'm'));
}
diff --git a/src/models/endpoints.js b/src/models/endpoints.js
index ff6394b..fa0420f 100644
--- a/src/models/endpoints.js
+++ b/src/models/endpoints.js
@@ -9,9 +9,9 @@ var clone = require('../lib/clone');
var NOT_FOUND = "Endpoint with the given id doesn't exist.";
var NO_MATCH = "Endpoint with given request doesn't exist.";
-function noop() {}
+function noop () {}
-function Endpoints(data, callback, datadir) {
+function Endpoints (data, callback, datadir) {
if (callback == null) { callback = noop; }
if (datadir == null) { datadir = process.cwd(); }
@@ -26,7 +26,7 @@ Endpoints.prototype.create = function (data, callback) {
if (callback == null) { callback = noop; }
- function insert(item) {
+ function insert (item) {
item = new Endpoint(item, self.datadir);
item.id = ++self.lastId;
self.db[item.id] = item;
@@ -129,7 +129,7 @@ Endpoints.prototype.found = function (endpoint, captures, callback) {
}
};
-function applyCaptures(obj, captures) {
+function applyCaptures (obj, captures) {
var results, key, value;
if (typeof obj === 'string') {
return ejs.render(obj.replace(/<%/g, '<%='), captures);
diff --git a/src/portals/admin.js b/src/portals/admin.js
index 530268b..9b01f17 100644
--- a/src/portals/admin.js
+++ b/src/portals/admin.js
@@ -6,7 +6,7 @@ var ns = require('node-static');
var path = require('path');
var status = new ns.Server(path.resolve(__dirname, '../../webroot'));
-function Admin(endpoints) {
+function Admin (endpoints) {
Portal.call(this);
this.server = this.server.bind(this);
this.endpoints = endpoints;
@@ -55,7 +55,7 @@ Admin.prototype.goDELETE = function (request, response) {
if (!id) { return this.notSupported(response); }
- function callback(err) {
+ function callback (err) {
if (err) { self.notFound(response); } else { self.noContent(response); }
}
@@ -75,7 +75,7 @@ Admin.prototype.goGET = function (request, response) {
return this.endpoints.retrieve(id, callback);
}
- callback = function (err, data) {
+ callback = function (_, data) {
if (data.length === 0) { self.noContent(response); } else { self.ok(response, data); }
};
@@ -91,7 +91,7 @@ Admin.prototype.processPUT = function (id, data, response) {
errors = this.contract(data);
if (errors) { return this.badRequest(response, errors); }
- function callback(err) {
+ function callback (err) {
if (err) { self.notFound(response); } else { self.noContent(response); }
}
@@ -106,7 +106,7 @@ Admin.prototype.processPOST = function (data, response, request) {
errors = this.contract(data);
if (errors) { return this.badRequest(response, errors); }
- function callback(err, endpoint) {
+ function callback (_, endpoint) {
self.created(response, request, endpoint.id);
}
diff --git a/src/portals/portal.js b/src/portals/portal.js
index 20efdc1..59c4bd0 100644
--- a/src/portals/portal.js
+++ b/src/portals/portal.js
@@ -4,7 +4,7 @@ var CLI = require('../console/cli');
var out = require('../console/out');
var http = require('http');
-function Portal() {
+function Portal () {
this.name = 'portal';
}
diff --git a/src/portals/stubs.js b/src/portals/stubs.js
index 2a7593a..9f20112 100644
--- a/src/portals/stubs.js
+++ b/src/portals/stubs.js
@@ -3,7 +3,7 @@
var Portal = require('./portal').Portal;
var qs = require('querystring');
-function Stubs(endpoints) {
+function Stubs (endpoints) {
Portal.call(this);
this.server = this.server.bind(this);
this.Endpoints = endpoints;
@@ -37,7 +37,7 @@ Stubs.prototype.server = function (request, response) {
query: extractQuery(request.url)
};
- function callback(err, endpointResponse) {
+ function callback (err, endpointResponse) {
if (err) {
self.writeHead(response, 404, {});
self.responded(404, request.url, 'is not a registered endpoint');
@@ -60,11 +60,11 @@ Stubs.prototype.server = function (request, response) {
});
};
-function extractUrl(url) {
+function extractUrl (url) {
return url.replace(/(.*)\?.*/, '$1');
}
-function extractQuery(url) {
+function extractQuery (url) {
return qs.parse(url.replace(/^.*\?(.*)$/, '$1'));
}
diff --git a/src/prototype/times.js b/src/prototype/times.js
index 6358c2e..6cdf2b1 100644
--- a/src/prototype/times.js
+++ b/src/prototype/times.js
@@ -1,7 +1,7 @@
'use strict';
/* eslint-disable no-extend-native */
-function noop() {}
+function noop () {}
Object.defineProperty(Number.prototype, 'times', {
configurable: true,
diff --git a/test/e2e.admin.js b/test/e2e.admin.js
index a742a2a..2aa506a 100644
--- a/test/e2e.admin.js
+++ b/test/e2e.admin.js
@@ -12,7 +12,7 @@ describe('End 2 End Admin Test Suite', function () {
var sut;
var port = 8889;
- function stopStubby(finish) {
+ function stopStubby (finish) {
if (sut != null) {
sut.stop(finish);
} else {
@@ -21,7 +21,7 @@ describe('End 2 End Admin Test Suite', function () {
}
beforeEach(function (done) {
- function finish() {
+ function finish () {
sut = new Stubby();
return sut.start({
data: endpointData
diff --git a/test/e2e.stubs.js b/test/e2e.stubs.js
index 3f41930..2789657 100644
--- a/test/e2e.stubs.js
+++ b/test/e2e.stubs.js
@@ -11,7 +11,7 @@ describe('End 2 End Stubs Test Suite', function () {
var sut = null;
var port = 8882;
- function stopStubby(finish) {
+ function stopStubby (finish) {
if (sut != null) {
return sut.stop(finish);
}
@@ -24,7 +24,7 @@ describe('End 2 End Stubs Test Suite', function () {
port: port
};
- function finish() {
+ function finish () {
sut = new Stubby();
sut.start({
data: endpointData
diff --git a/test/endpoint.js b/test/endpoint.js
index 7b2b812..ab10c6b 100644
--- a/test/endpoint.js
+++ b/test/endpoint.js
@@ -3,7 +3,7 @@
var Endpoint = require('../src/models/endpoint');
var assert = require('assert');
-function waitsFor(fn, message, range, finish, time) {
+function waitsFor (fn, message, range, finish, time) {
var temp, seconds, nanoseconds, elapsed;
var min = range[0] != null ? range[0] : 0;
var max = range[1] != null ? range[1] : range;
@@ -27,7 +27,7 @@ function waitsFor(fn, message, range, finish, time) {
}, 1);
}
-function compareOneWay(left, right) {
+function compareOneWay (left, right) {
var key, value;
for (key in left) {
@@ -47,7 +47,7 @@ function compareOneWay(left, right) {
return true;
}
-function compareObjects(one, two) {
+function compareObjects (one, two) {
return compareOneWay(one, two) && compareOneWay(two, one);
}
diff --git a/test/endpoints.js b/test/endpoints.js
index a99eb6b..ae9d780 100644
--- a/test/endpoints.js
+++ b/test/endpoints.js
@@ -193,7 +193,7 @@ describe('Endpoints', function () {
post: 'hello, there!'
};
- sut.find(data, function (err, match) {
+ sut.find(data, function (_, match) {
assert.strictEqual(match.body, 'you posted "hello, there!" and "hello, there!"');
done();
});
diff --git a/test/main.js b/test/main.js
index 6fab214..3720637 100644
--- a/test/main.js
+++ b/test/main.js
@@ -8,7 +8,7 @@ var Stubby = require('../src/main').Stubby;
describe('main', function () {
var sut, options;
- function stopStubby(finish) {
+ function stopStubby (finish) {
if (sut != null) {
sut.stop(finish);
} else {
@@ -17,7 +17,7 @@ describe('main', function () {
}
beforeEach(function (done) {
- function finish() {
+ function finish () {
sut = new Stubby();
done();
}
diff --git a/webroot/js/scripts.js b/webroot/js/scripts.js
index b5e72c2..3decfa8 100644
--- a/webroot/js/scripts.js
+++ b/webroot/js/scripts.js
@@ -1,134 +1,135 @@
-(function(window) {
+/* global _, hljs */
+(function (window) {
var stubby = window.stubby || {};
var template = [ // eww
- '
',
- ' ',
- ' Endpoint <%= id %>',
- ' ',
- ' request | ',
- '
',
- ' ',
- ' url | ',
- ' <%= request.url %> | ',
- '
',
- ' <% if(request.method) { %>',
- ' ',
- ' method | ',
- ' <%= request.method %> | ',
- '
',
- ' <% } if(request.query) { %>',
- ' ',
- ' query | ',
- ' <% print(queryParams(request.query)); %> | ',
- '
',
- ' ',
- ' | ',
- ' ',
- ' ',
- ' <% _.each(_.keys(request.query), function(key) { %>',
- ' - ',
- '
- <%= key %>
',
- ' - <%= request.query[key] %>
',
- ' ',
- ' <% }); %>',
- ' ',
- ' | ',
- '
',
- ' <% } if(request.headers && Object.keys(request.headers).length > 0) { %>',
- ' ',
- ' headers | ',
- ' ',
- ' ',
- ' <% _.each(_.keys(request.headers), function(key) { %>',
- ' - ',
- '
- <%= key %>
',
- ' - <%= request.headers[key] %>
',
- ' ',
- ' <% }); %>',
- ' ',
- ' | ',
- '
',
- ' <% } if(request.post) { %>',
- ' ',
- ' post | ',
- ' <%= request.post %>
| ',
- '
',
- ' <% } if(request.file) { %>',
- ' ',
- ' file | ',
- ' <%= request.file %> | ',
- '
',
- ' <% } %>',
- ' ',
- ' response | ',
- '
',
- ' <% if(response.status) { %>',
- ' ',
- ' status | ',
- ' <%= response.status %> | ',
- '
',
- ' <% } if(response.headers && Object.keys(response.headers).length > 0) { %>',
- ' ',
- ' headers | ',
- ' ',
- ' ',
- ' <% _.each(_.keys(response.headers), function(key) { %>',
- ' - ',
- '
- <%= key %>
',
- ' - <%= response[0].headers[key] %>
',
- ' ',
- ' <% }); %>',
- ' ',
- ' | ',
- '
',
- ' <% } if(response[0].body) { %>',
- ' ',
- ' body | ',
- ' <%= response[0].body %>
| ',
- '
',
- ' <% } if(response[0].file) { %>',
- ' ',
- ' file | ',
- ' <%= response[0].file %> | ',
- '
',
- ' <% } if(response[0].latency) { %>',
- ' ',
- ' latency | ',
- ' <%= response[0].latency %> | ',
- '
',
- ' <% } %>',
- ' ',
- ' hits | ',
- ' <%= hits %> | ',
- '
',
- '
',
- '',
+ '',
+ ' ',
+ ' Endpoint <%= id %>',
+ ' ',
+ ' request | ',
+ '
',
+ ' ',
+ ' url | ',
+ ' <%= request.url %> | ',
+ '
',
+ ' <% if(request.method) { %>',
+ ' ',
+ ' method | ',
+ ' <%= request.method %> | ',
+ '
',
+ ' <% } if(request.query) { %>',
+ ' ',
+ ' query | ',
+ ' <% print(queryParams(request.query)); %> | ',
+ '
',
+ ' ',
+ ' | ',
+ ' ',
+ ' ',
+ ' <% _.each(_.keys(request.query), function(key) { %>',
+ ' - ',
+ '
- <%= key %>
',
+ ' - <%= request.query[key] %>
',
+ ' ',
+ ' <% }); %>',
+ ' ',
+ ' | ',
+ '
',
+ ' <% } if(request.headers && Object.keys(request.headers).length > 0) { %>',
+ ' ',
+ ' headers | ',
+ ' ',
+ ' ',
+ ' <% _.each(_.keys(request.headers), function(key) { %>',
+ ' - ',
+ '
- <%= key %>
',
+ ' - <%= request.headers[key] %>
',
+ ' ',
+ ' <% }); %>',
+ ' ',
+ ' | ',
+ '
',
+ ' <% } if(request.post) { %>',
+ ' ',
+ ' post | ',
+ ' <%= request.post %>
| ',
+ '
',
+ ' <% } if(request.file) { %>',
+ ' ',
+ ' file | ',
+ ' <%= request.file %> | ',
+ '
',
+ ' <% } %>',
+ ' ',
+ ' response | ',
+ '
',
+ ' <% if(response.status) { %>',
+ ' ',
+ ' status | ',
+ ' <%= response.status %> | ',
+ '
',
+ ' <% } if(response.headers && Object.keys(response.headers).length > 0) { %>',
+ ' ',
+ ' headers | ',
+ ' ',
+ ' ',
+ ' <% _.each(_.keys(response.headers), function(key) { %>',
+ ' - ',
+ '
- <%= key %>
',
+ ' - <%= response[0].headers[key] %>
',
+ ' ',
+ ' <% }); %>',
+ ' ',
+ ' | ',
+ '
',
+ ' <% } if(response[0].body) { %>',
+ ' ',
+ ' body | ',
+ ' <%= response[0].body %>
| ',
+ '
',
+ ' <% } if(response[0].file) { %>',
+ ' ',
+ ' file | ',
+ ' <%= response[0].file %> | ',
+ '
',
+ ' <% } if(response[0].latency) { %>',
+ ' ',
+ ' latency | ',
+ ' <%= response[0].latency %> | ',
+ '
',
+ ' <% } %>',
+ ' ',
+ ' hits | ',
+ ' <%= hits %> | ',
+ '
',
+ '
',
+ ''
].join('\n');
- function queryParams(query) {
- var result = "?";
+ function queryParams (query) {
+ var result = '?';
for (var key in query) {
var value = query[key];
result += encodeURIComponent(key);
- result += "=";
+ result += '=';
result += encodeURIComponent(value);
- result += "&";
+ result += '&';
}
- return result.replace(/\&$/, '');
- };
+ return result.replace(/&$/, '');
+ }
var ajax = null;
var list = null;
- function success() {
- var endpoint, _fn, _i, _len;
+ function success () {
+ var endpoint;
var endpoints = JSON.parse(ajax.responseText);
for (var i = 0; i < endpoints.length; i++) {
- var endpoint = endpoints[i];
+ endpoint = endpoints[i];
endpoint.queryParams = queryParams;
endpoint.adminUrl = window.location.href.replace(/status/, endpoint.id);
@@ -140,14 +141,13 @@
hljs.initHighlighting();
}
- function complete(e) {
+ function complete (e) {
if (ajax.readyState !== 4) { return; }
- if (ajax.status === 200) { return success(); }
- else { return console.error(ajax.statusText); }
+ if (ajax.status === 200) { return success(); } else { return console.error(ajax.statusText); }
}
- stubby.status = function() {
+ stubby.status = function () {
list = document.getElementById('endpoints');
ajax = new window.XMLHttpRequest();