adapting scode eslint standard config

This commit is contained in:
Timo Hocker 2020-01-03 19:13:21 +01:00
parent 4bd4740a86
commit 78dfe76a43
26 changed files with 385 additions and 268 deletions

View File

@ -5,7 +5,7 @@ module.exports = {
node: true
},
extends: [
'standard'
'@scode'
],
globals: {
Atomics: 'readonly',
@ -13,8 +13,5 @@ module.exports = {
},
parserOptions: {
ecmaVersion: 2018
},
rules: {
semi: 0
}
}

View File

@ -1,8 +1,10 @@
const fs = require('fs');
const path = require('path');
/* eslint-disable no-console */
/* eslint-disable no-sync */
const fs = require ('fs');
const path = require ('path');
/**
* @typedef {Object} options
* @typedef {object} options
* @property {any} [opts] object to pass to the handlers
* @property {string} [subdir] subdirectory for all requests
* @property {boolean} [verbose] enable verbose logging
@ -13,52 +15,57 @@ const path = require('path');
*
* @param {any} app express app
* @param {string} modulefolder folder that contains all modules
* @param {options} options
* @param {options} options additional options
*/
module.exports = function (
module.exports = function main (
app,
modulefolder,
options = { opts: undefined, subdir: '', verbose: false }
options = { opts: null, subdir: '', verbose: false }
) {
const { opts, subdir, verbose } = options;
for (const f of fs.readdirSync(modulefolder)) {
const regex = /(.*?)-(.*?)\.js/;
let [, method, url] = regex.exec(f);
url = '/' + subdir + '/' + url + '/';
url = url
.replace(/^\/[^/]*\/root/i, '/')
.replace(/\./g, '/')
.replace(/\/+/g, '/');
for (const f of fs.readdirSync (modulefolder)) {
const regex = /(?<method>.*?)-(?<url>.*?)\.js/u;
const { groups } = regex.exec (f);
groups.url = `/${subdir}/${groups.url}/`;
groups.url = groups.url
.replace (/^\/[^/]*\/root/iu, '/')
.replace (/\./gu, '/')
.replace (/\/+/gu, '/');
const handler = require(path.join(process.cwd(), modulefolder, f));
const func = (req, res, next) => {
handler(req, res, next, opts);
// eslint-disable-next-line global-require
const handler = require (path.join (process.cwd (), modulefolder, f));
const requestor_handler = (req, res, next) => {
handler (req, res, next, opts);
};
if (verbose) console.log(`[requestor info] redirecting ${url} to ${f}`);
if (verbose)
console.log (`[requestor info] redirecting ${groups.url} to ${f}`);
switch (method) {
case 'post':
app.post(url, func);
break;
case 'get':
app.get(url, func);
break;
case 'put':
app.put(url, func);
break;
case 'delete':
app.delete(url, func);
break;
case 'all':
app.all(url, func);
break;
default:
if (verbose) {
console.warn(`'${method}' did not match any request method, ignoring`);
}
break;
switch (groups.method) {
case 'post':
app.post (groups.url, requestor_handler);
break;
case 'get':
app.get (groups.url, requestor_handler);
break;
case 'put':
app.put (groups.url, requestor_handler);
break;
case 'delete':
app.delete (groups.url, requestor_handler);
break;
case 'all':
app.all (groups.url, requestor_handler);
break;
default:
if (verbose)
console.warn (
`'${groups.method}' did not match any request method, ignoring`
);
break;
}
}
};

View File

@ -1,5 +1,7 @@
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
pkg.version = process.argv[2];
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
const fs = require ('fs');
const pkg = JSON.parse (fs.readFileSync ('package.json', 'utf-8'));
[
,, pkg.version
] = process.argv;
fs.writeFileSync ('package.json', JSON.stringify (pkg, null, 2));

275
package-lock.json generated
View File

@ -24,6 +24,16 @@
"js-tokens": "^4.0.0"
}
},
"@scode/eslint-config": {
"version": "1.0.21",
"resolved": "https://npm.scode.ovh/@scode%2feslint-config/-/eslint-config-1.0.21.tgz",
"integrity": "sha512-v5oF/hFM5qvoUSVJtVGBou3Uu7NDqc91c28YtGUcMXwtRsj0ZjEE+rC4Nd08OhApYHU7rwczqRG06x0/ecVhYQ==",
"dev": true,
"requires": {
"eslint-plugin-jsdoc": "^18.4.4",
"eslint-plugin-vue": "^6.0.1"
}
},
"acorn": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz",
@ -88,24 +98,24 @@
}
},
"array-includes": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.0.3.tgz",
"integrity": "sha1-GEtI9i2S10UrsxsyMWXH+L0CJm0=",
"dev": true,
"requires": {
"define-properties": "^1.1.2",
"es-abstract": "^1.7.0"
}
},
"array.prototype.flat": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.2.tgz",
"integrity": "sha512-VXjh7lAL4KXKF2hY4FnEW9eRW6IhdvFW1sN/JwLbmECbCgACCnBHNyP3lFiYuttr0jxRN9Bsc5+G27dMseSWqQ==",
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.1.tgz",
"integrity": "sha512-c2VXaCHl7zPsvpkFsw4nxvFie4fh1ur9bpcgsVkIjqn0H/Xwdg+7fv3n2r/isyS8EBj5b06M9kHyZuIr4El6WQ==",
"dev": true,
"requires": {
"define-properties": "^1.1.3",
"es-abstract": "^1.15.0",
"function-bind": "^1.1.1"
"es-abstract": "^1.17.0",
"is-string": "^1.0.5"
}
},
"array.prototype.flat": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.3.tgz",
"integrity": "sha512-gBlRZV0VSmfPIeWfuuy56XZMvbVfbEUnOXUvt3F/eUUUSyzlgLxhEX4YAEpxNAogRGehPSnfXyPtYyKAhkzQhQ==",
"dev": true,
"requires": {
"define-properties": "^1.1.3",
"es-abstract": "^1.17.0-next.1"
}
},
"assertion-error": {
@ -257,6 +267,12 @@
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
"dev": true
},
"comment-parser": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-0.7.2.tgz",
"integrity": "sha512-4Rjb1FnxtOcv9qsfuaNuVsmmVn4ooVoBHzYfyKteiXwIU84PClyGA5jASoFMwPV93+FPh9spwueXauxFJZkGAg==",
"dev": true
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@ -360,21 +376,22 @@
}
},
"es-abstract": {
"version": "1.16.3",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.16.3.tgz",
"integrity": "sha512-WtY7Fx5LiOnSYgF5eg/1T+GONaGmpvpPdCpSnYij+U2gDTL0UPfWrhDw7b2IYb+9NQJsYpCA0wOQvZfsd6YwRw==",
"version": "1.17.0",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.0.tgz",
"integrity": "sha512-yYkE07YF+6SIBmg1MsJ9dlub5L48Ek7X0qz+c/CPCHS9EBXfESorzng4cJQjJW5/pB6vDF41u7F8vUhLVDqIug==",
"dev": true,
"requires": {
"es-to-primitive": "^1.2.1",
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-symbols": "^1.0.1",
"is-callable": "^1.1.4",
"is-regex": "^1.0.4",
"is-callable": "^1.1.5",
"is-regex": "^1.0.5",
"object-inspect": "^1.7.0",
"object-keys": "^1.1.1",
"string.prototype.trimleft": "^2.1.0",
"string.prototype.trimright": "^2.1.0"
"object.assign": "^4.1.0",
"string.prototype.trimleft": "^2.1.1",
"string.prototype.trimright": "^2.1.1"
}
},
"es-to-primitive": {
@ -395,9 +412,9 @@
"dev": true
},
"eslint": {
"version": "6.7.2",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-6.7.2.tgz",
"integrity": "sha512-qMlSWJaCSxDFr8fBPvJM9kJwbazrhNcBU3+DszDW1OlEwKBBRWsJc7NJFelvwQpanHCR14cOLD41x8Eqvo3Nng==",
"version": "6.8.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz",
"integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
@ -500,15 +517,24 @@
}
},
"eslint-plugin-es": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-2.0.0.tgz",
"integrity": "sha512-f6fceVtg27BR02EYnBhgWLFQfK6bN4Ll0nQFrBHOlCsAyxeZkn0NHns5O0YZOPrV1B3ramd6cgFwaoFLcSkwEQ==",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.0.tgz",
"integrity": "sha512-6/Jb/J/ZvSebydwbBJO1R9E5ky7YeElfK56Veh7e4QGFHCXoIXGH9HhVz+ibJLM3XJ1XjP+T7rKBLUa/Y7eIng==",
"dev": true,
"requires": {
"eslint-utils": "^1.4.2",
"eslint-utils": "^2.0.0",
"regexpp": "^3.0.0"
},
"dependencies": {
"eslint-utils": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.0.0.tgz",
"integrity": "sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA==",
"dev": true,
"requires": {
"eslint-visitor-keys": "^1.1.0"
}
},
"regexpp": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.0.0.tgz",
@ -564,20 +590,45 @@
}
}
},
"eslint-plugin-node": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-10.0.0.tgz",
"integrity": "sha512-1CSyM/QCjs6PXaT18+zuAXsjXGIGo5Rw630rSKwokSs2jrYURQc4R5JZpoanNCqwNmepg+0eZ9L7YiRUJb8jiQ==",
"eslint-plugin-jsdoc": {
"version": "18.11.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-18.11.0.tgz",
"integrity": "sha512-24J2+eK2ZHZ1KvpKcoOEir2k4xJKfPzZ1JC9PToi8y8Tn59T8TVVSNRTTRzsDdiaQeIbehApB3KxqIfJG8o7hg==",
"dev": true,
"requires": {
"eslint-plugin-es": "^2.0.0",
"eslint-utils": "^1.4.2",
"comment-parser": "^0.7.2",
"debug": "^4.1.1",
"jsdoctypeparser": "^6.1.0",
"lodash": "^4.17.15",
"object.entries-ponyfill": "^1.0.1",
"regextras": "^0.7.0",
"semver": "^6.3.0",
"spdx-expression-parse": "^3.0.0"
}
},
"eslint-plugin-node": {
"version": "11.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.0.0.tgz",
"integrity": "sha512-chUs/NVID+sknFiJzxoN9lM7uKSOEta8GC8365hw1nDfwIPIjjpRSwwPvQanWv8dt/pDe9EV4anmVSwdiSndNg==",
"dev": true,
"requires": {
"eslint-plugin-es": "^3.0.0",
"eslint-utils": "^2.0.0",
"ignore": "^5.1.1",
"minimatch": "^3.0.4",
"resolve": "^1.10.1",
"semver": "^6.1.0"
},
"dependencies": {
"eslint-utils": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.0.0.tgz",
"integrity": "sha512-0HCPuJv+7Wv1bACm8y5/ECVfYdfsAm9xmVb7saeFlxjPYALefjhbYoCkBjPdPzGH8wWyTpAez82Fh3VKYEZ8OA==",
"dev": true,
"requires": {
"eslint-visitor-keys": "^1.1.0"
}
},
"ignore": {
"version": "5.1.4",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.4.tgz",
@ -598,6 +649,24 @@
"integrity": "sha512-v/KBnfyaOMPmZc/dmc6ozOdWqekGp7bBGq4jLAecEfPGmfKiWS4sA8sC0LqiV9w5qmXAtXVn4M3p1jSyhY85SQ==",
"dev": true
},
"eslint-plugin-vue": {
"version": "6.1.2",
"resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-6.1.2.tgz",
"integrity": "sha512-M75oAB+2a/LNkLKRbeEaS07EjzjIUaV7/hYoHAfRFeeF8ZMmCbahUn8nQLsLP85mkar24+zDU3QW2iT1JRsACw==",
"dev": true,
"requires": {
"semver": "^5.6.0",
"vue-eslint-parser": "^7.0.0"
},
"dependencies": {
"semver": {
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"dev": true
}
}
},
"eslint-scope": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz",
@ -688,9 +757,9 @@
"dev": true
},
"fast-json-stable-stringify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==",
"dev": true
},
"fast-levenshtein": {
@ -907,9 +976,9 @@
"dev": true
},
"inquirer": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.0.tgz",
"integrity": "sha512-rSdC7zelHdRQFkWnhsMu2+2SO41mpv2oF2zy4tMhmiLWkcKbOAs87fWAJhVXttKVwhdZvymvnuM95EyEXg2/tQ==",
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.1.tgz",
"integrity": "sha512-V1FFQ3TIO15det8PijPLFR9M9baSlnRs9nL7zWu1MNVA2T9YVl9ZbrHJhYs7e9X8jeMZ3lr2JH/rdHFgNCBdYw==",
"dev": true,
"requires": {
"ansi-escapes": "^4.2.1",
@ -921,7 +990,7 @@
"lodash": "^4.17.15",
"mute-stream": "0.0.8",
"run-async": "^2.2.0",
"rxjs": "^6.4.0",
"rxjs": "^6.5.3",
"string-width": "^4.1.0",
"strip-ansi": "^5.1.0",
"through": "^2.3.6"
@ -940,15 +1009,15 @@
"dev": true
},
"is-callable": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz",
"integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==",
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz",
"integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==",
"dev": true
},
"is-date-object": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz",
"integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz",
"integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==",
"dev": true
},
"is-extglob": {
@ -979,14 +1048,20 @@
"dev": true
},
"is-regex": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz",
"integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=",
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz",
"integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==",
"dev": true,
"requires": {
"has": "^1.0.1"
"has": "^1.0.3"
}
},
"is-string": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz",
"integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==",
"dev": true
},
"is-symbol": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz",
@ -1024,6 +1099,12 @@
"esprima": "^4.0.0"
}
},
"jsdoctypeparser": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/jsdoctypeparser/-/jsdoctypeparser-6.1.0.tgz",
"integrity": "sha512-UCQBZ3xCUBv/PLfwKAJhp6jmGOSLFNKzrotXGNgbKhWvz27wPsCsVeP7gIcHPElQw2agBmynAitXqhxR58XAmA==",
"dev": true
},
"json-schema-traverse": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
@ -1193,9 +1274,9 @@
"dev": true
},
"p-limit": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz",
"integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==",
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.2.tgz",
"integrity": "sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ==",
"dev": true,
"requires": {
"p-try": "^2.0.0"
@ -1319,24 +1400,30 @@
"object-keys": "^1.0.11"
}
},
"object.getownpropertydescriptors": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz",
"integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=",
"dev": true,
"requires": {
"define-properties": "^1.1.2",
"es-abstract": "^1.5.1"
}
"object.entries-ponyfill": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/object.entries-ponyfill/-/object.entries-ponyfill-1.0.1.tgz",
"integrity": "sha1-Kavfd8v70mVm3RqiTp2I9lQz0lY=",
"dev": true
},
"object.values": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.0.tgz",
"integrity": "sha512-8mf0nKLAoFX6VlNVdhGj31SVYpaNFtUnuoOXWyFEstsWRgU837AK+JYM0iAxwkSzGRbwn8cbFmgbyxj1j4VbXg==",
"object.getownpropertydescriptors": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.0.tgz",
"integrity": "sha512-Z53Oah9A3TdLoblT7VKJaTDdXdT+lQO+cNpKVnya5JDe9uLvzu1YyY1yFDFrcxrlRgWrEFH0jJtD/IbuwjcEVg==",
"dev": true,
"requires": {
"define-properties": "^1.1.3",
"es-abstract": "^1.12.0",
"es-abstract": "^1.17.0-next.1"
}
},
"object.values": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.1.tgz",
"integrity": "sha512-WTa54g2K8iu0kmS/us18jEmdv1a4Wi//BZ/DTVYEcH0XhLM5NYdpDHja3gt57VrZLcNAO2WGA+KpWsDBaHt6eA==",
"dev": true,
"requires": {
"define-properties": "^1.1.3",
"es-abstract": "^1.17.0-next.1",
"function-bind": "^1.1.1",
"has": "^1.0.3"
}
@ -1520,6 +1607,12 @@
"integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==",
"dev": true
},
"regextras": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/regextras/-/regextras-0.7.0.tgz",
"integrity": "sha512-ds+fL+Vhl918gbAUb0k2gVKbTZLsg84Re3DI6p85Et0U0tYME3hyW4nMK8Px4dtDaBA2qNjvG5uWyW7eK5gfmw==",
"dev": true
},
"require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
@ -1533,9 +1626,9 @@
"dev": true
},
"resolve": {
"version": "1.13.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.13.1.tgz",
"integrity": "sha512-CxqObCX8K8YtAhOBRg+lrcdn+LK+WYOS8tSjqSFbjtrI5PnS63QPhZl4+yKfrU9tdsbMu9Anr/amegT87M9Z6w==",
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.14.1.tgz",
"integrity": "sha512-fn5Wobh4cxbLzuHaE+nphztHy43/b++4M6SsGFC2gB8uYwf0C8LcarfCz1un7UTW8OFQg9iNjZ4xpcFVGebDPg==",
"dev": true,
"requires": {
"path-parse": "^1.0.6"
@ -1576,9 +1669,9 @@
}
},
"rxjs": {
"version": "6.5.3",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.3.tgz",
"integrity": "sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA==",
"version": "6.5.4",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.4.tgz",
"integrity": "sha512-naMQXcgEo3csAEGvw/NydRA0fuS2nDZJiw1YUWFKU7aPPAPGZEsD4Iimit96qwCieH6y614MCLYwdkrWx7z/7Q==",
"dev": true,
"requires": {
"tslib": "^1.9.0"
@ -1703,9 +1796,9 @@
}
},
"string.prototype.trimleft": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz",
"integrity": "sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw==",
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz",
"integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==",
"dev": true,
"requires": {
"define-properties": "^1.1.3",
@ -1713,9 +1806,9 @@
}
},
"string.prototype.trimright": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz",
"integrity": "sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg==",
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz",
"integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==",
"dev": true,
"requires": {
"define-properties": "^1.1.3",
@ -1870,6 +1963,20 @@
"spdx-expression-parse": "^3.0.0"
}
},
"vue-eslint-parser": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-7.0.0.tgz",
"integrity": "sha512-yR0dLxsTT7JfD2YQo9BhnQ6bUTLsZouuzt9SKRP7XNaZJV459gvlsJo4vT2nhZ/2dH9j3c53bIx9dnqU2prM9g==",
"dev": true,
"requires": {
"debug": "^4.1.1",
"eslint-scope": "^5.0.0",
"eslint-visitor-keys": "^1.1.0",
"espree": "^6.1.2",
"esquery": "^1.0.1",
"lodash": "^4.17.15"
}
},
"which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
@ -2040,9 +2147,9 @@
}
},
"p-limit": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz",
"integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==",
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.2.tgz",
"integrity": "sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ==",
"dev": true,
"requires": {
"p-try": "^2.0.0"

View File

@ -16,11 +16,12 @@
"author": "Timo Hocker",
"license": "GPL-3.0-or-later",
"devDependencies": {
"@scode/eslint-config": "^1.0.21",
"chai": "^4.2.0",
"eslint": "^6.7.2",
"eslint": "^6.8.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"mocha": "^6.2.2"

View File

@ -1,77 +1,77 @@
const { describe, it, beforeEach } = require('mocha');
const expect = require('chai').expect;
const requestor = require('../index');
const mock = {
registered: {},
post: function (path, handler) {
this.registered['post-' + path] = handler;
},
get: function (path, handler) {
this.registered['get-' + path] = handler;
},
put: function (path, handler) {
this.registered['put-' + path] = handler;
},
delete: function (path, handler) {
this.registered['delete-' + path] = handler;
},
all: function (path, handler) {
this.registered['all-' + path] = handler;
}
};
describe('requestor', () => {
beforeEach(() => {
mock.registered = {};
});
it('should detect all requests on root', () => {
requestor(mock, './test/root');
expect(mock.registered).to.have.all.keys([
'post-/',
'get-/',
'put-/',
'delete-/',
'all-/'
]);
});
it('should detect requests on root.subfolder', () => {
requestor(mock, './test/root.sub');
expect(mock.registered).to.have.all.keys([
'post-/sub/',
'get-/sub/',
'put-/sub/',
'delete-/sub/',
'all-/sub/'
]);
});
it('should detect requests on subfolder', () => {
requestor(mock, './test/sub');
expect(mock.registered).to.have.all.keys([
'post-/sub/',
'get-/sub/',
'put-/sub/',
'delete-/sub/',
'all-/sub/',
'get-/sub/lv1/lv2/lv3/',
'all-/sub/root/'
]);
});
it('should build requests with subdirectory', () => {
requestor(mock, './test/sub', { subdir: 'test' });
expect(mock.registered).to.have.all.keys([
'post-/test/sub/',
'get-/test/sub/',
'put-/test/sub/',
'delete-/test/sub/',
'all-/test/sub/',
'get-/test/sub/lv1/lv2/lv3/',
'all-/test/sub/root/'
]);
});
});
const { describe, it, beforeEach: before_each } = require ('mocha');
const { expect } = require ('chai');
const requestor = require ('../index');
const mock = {
registered: {},
post (path, handler) {
this.registered[`post-${path}`] = handler;
},
get (path, handler) {
this.registered[`get-${path}`] = handler;
},
put (path, handler) {
this.registered[`put-${path}`] = handler;
},
delete (path, handler) {
this.registered[`delete-${path}`] = handler;
},
all (path, handler) {
this.registered[`all-${path}`] = handler;
}
};
describe ('requestor', () => {
before_each (() => {
mock.registered = {};
});
it ('should detect all requests on root', () => {
requestor (mock, './test/root');
expect (mock.registered).to.have.all.keys ([
'post-/',
'get-/',
'put-/',
'delete-/',
'all-/'
]);
});
it ('should detect requests on root.subfolder', () => {
requestor (mock, './test/root.sub');
expect (mock.registered).to.have.all.keys ([
'post-/sub/',
'get-/sub/',
'put-/sub/',
'delete-/sub/',
'all-/sub/'
]);
});
it ('should detect requests on subfolder', () => {
requestor (mock, './test/sub');
expect (mock.registered).to.have.all.keys ([
'post-/sub/',
'get-/sub/',
'put-/sub/',
'delete-/sub/',
'all-/sub/',
'get-/sub/lv1/lv2/lv3/',
'all-/sub/root/'
]);
});
it ('should build requests with subdirectory', () => {
requestor (mock, './test/sub', { subdir: 'test' });
expect (mock.registered).to.have.all.keys ([
'post-/test/sub/',
'get-/test/sub/',
'put-/test/sub/',
'delete-/test/sub/',
'all-/test/sub/',
'get-/test/sub/lv1/lv2/lv3/',
'all-/test/sub/root/'
]);
});
});

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -0,0 +1,3 @@
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};

View File

@ -1,3 +1,3 @@
module.exports = (req, res, next, opts) => {
// dummy endpoint: do nothing
};
module.exports = () => {
// dummy endpoint: do nothing
};