diff --git a/CHANGELOG.md b/CHANGELOG.md index 307231e..ea6f65e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Chat to the bingo game (renderd with markdown-it) - Postgres session storage - sql-file directory `sql` - +- LICENSE.md (GPL v3) +- eslint to dev dependencys ## Changed @@ -28,3 +29,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - mobile layout +- code style issues +- Bingo button not shown on refresh diff --git a/README.md b/README.md index 26dab37..8b99c27 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# whooshy +# whooshy [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg?style=flat-square)](https://www.gnu.org/licenses/gpl-3.0) This repository is the node.js webserver running on `(beta.)trivernis.net`. diff --git a/app.js b/app.js index a6b7c73..858aac3 100644 --- a/app.js +++ b/app.js @@ -29,7 +29,7 @@ async function init() { return { time: Date.now(), bingo: bingoRouter.graphqlResolver(request, response) - } + }; }; // database setup let pgPool = new pg.Pool({ @@ -91,7 +91,7 @@ async function init() { }); // error handler - app.use(function(err, req, res, next) { + app.use(function(err, req, res) { // set locals, only providing error in development res.locals.message = err.message; res.locals.error = req.app.get('env') === 'development' ? err : {}; diff --git a/bin/www b/bin/www index 9c787e9..2a09075 100644 --- a/bin/www +++ b/bin/www @@ -41,7 +41,7 @@ appInit().then((app) => { */ server.listen(port); - server.on('error', (error) => onError(error, server)); + server.on('error', (error) => onError(error)); server.on('listening', () => onListening(server)); /** @@ -55,16 +55,12 @@ appInit().then((app) => { function normalizePort(val) { let port = parseInt(val, 10); - if (isNaN(port)) { + if (isNaN(port)) // named pipe return val; - } - - if (port >= 0) { + if (port >= 0) // port number return port; - } - return false; } @@ -72,10 +68,9 @@ function normalizePort(val) { * Event listener for HTTP server "error" event. */ -function onError(error, server) { - if (error.syscall !== 'listen') { +function onError(error) { + if (error.syscall !== 'listen') throw error; - } let bind = typeof port === 'string' ? 'Pipe ' + port diff --git a/package-lock.json b/package-lock.json index 7011e05..9643799 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,26 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@babel/code-frame": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", + "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", + "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + } + }, "@types/babel-types": { "version": "7.0.7", "resolved": "https://registry.npmjs.org/@types/babel-types/-/babel-types-7.0.7.tgz", @@ -51,6 +71,12 @@ } } }, + "acorn-jsx": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.1.tgz", + "integrity": "sha512-HJ7CfNHrfJLlNTzIEUTj43LNWGkqpRLxm3YjAlcD0ACydk9XynzYsCBHxut+iqt+1aBXkx9UP/w/ZqMr13XIzg==", + "dev": true + }, "ajv": { "version": "6.10.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", @@ -87,6 +113,12 @@ "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=" }, + "ansi-escapes": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz", + "integrity": "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==", + "dev": true + }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", @@ -194,6 +226,12 @@ "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=" }, + "astral-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", + "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", + "dev": true + }, "async-each": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", @@ -433,6 +471,12 @@ "unset-value": "^1.0.0" } }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + }, "camelcase": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", @@ -486,6 +530,12 @@ "is-regex": "^1.0.3" } }, + "chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", + "dev": true + }, "chokidar": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.5.tgz", @@ -541,6 +591,21 @@ } } }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "dev": true, + "requires": { + "restore-cursor": "^2.0.0" + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "dev": true + }, "cliui": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", @@ -664,6 +729,16 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, + "cross-fetch": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-2.2.2.tgz", + "integrity": "sha1-pH/09/xxLauo9qaVoRyUhEDUVyM=", + "dev": true, + "requires": { + "node-fetch": "2.1.2", + "whatwg-fetch": "2.0.4" + } + }, "cross-spawn": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-3.0.1.tgz", @@ -719,6 +794,12 @@ "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=" }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, "define-property": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", @@ -776,6 +857,15 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, "doctypes": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/doctypes/-/doctypes-1.1.0.tgz", @@ -795,6 +885,12 @@ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -823,11 +919,166 @@ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, + "eslint": { + "version": "5.16.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz", + "integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "ajv": "^6.9.1", + "chalk": "^2.1.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "eslint-scope": "^4.0.3", + "eslint-utils": "^1.3.1", + "eslint-visitor-keys": "^1.0.0", + "espree": "^5.0.1", + "esquery": "^1.0.1", + "esutils": "^2.0.2", + "file-entry-cache": "^5.0.1", + "functional-red-black-tree": "^1.0.1", + "glob": "^7.1.2", + "globals": "^11.7.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "inquirer": "^6.2.2", + "js-yaml": "^3.13.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.11", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.2", + "path-is-inside": "^1.0.2", + "progress": "^2.0.0", + "regexpp": "^2.0.1", + "semver": "^5.5.1", + "strip-ansi": "^4.0.0", + "strip-json-comments": "^2.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "eslint-plugin-graphql": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-graphql/-/eslint-plugin-graphql-3.0.3.tgz", + "integrity": "sha512-hHwLyxSkC5rkakJ/SNTWwOswPdVhvfyMCnEOloevrLQIOHUNVIQBg1ljCaRe9C40HdzgcGUFUdG5BHLCKm8tuw==", + "dev": true, + "requires": { + "graphql-config": "^2.0.1", + "lodash": "^4.11.1" + } + }, + "eslint-plugin-promise": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-4.1.1.tgz", + "integrity": "sha512-faAHw7uzlNPy7b45J1guyjazw28M+7gJokKUjC5JSFoYfUEyy6Gw/i7YQvmv2Yk00sUjWcmzXQLpU1Ki/C2IZQ==", + "dev": true + }, + "eslint-scope": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", + "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, + "eslint-utils": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.3.1.tgz", + "integrity": "sha512-Z7YjnIldX+2XMcjr7ZkgEsOj/bREONV60qYeB/bjMAqqqZ4zxKyWX+BOUkdmRmA9riiIPVvo5x86m5elviOk0Q==", + "dev": true + }, + "eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", + "dev": true + }, + "espree": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz", + "integrity": "sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==", + "dev": true, + "requires": { + "acorn": "^6.0.7", + "acorn-jsx": "^5.0.0", + "eslint-visitor-keys": "^1.0.0" + }, + "dependencies": { + "acorn": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", + "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==", + "dev": true + } + } + }, "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" }, + "esquery": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", + "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "dev": true, + "requires": { + "estraverse": "^4.0.0" + } + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "dev": true, + "requires": { + "estraverse": "^4.1.0" + } + }, + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + }, "esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", @@ -1025,6 +1276,28 @@ } } }, + "external-editor": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.3.tgz", + "integrity": "sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA==", + "dev": true, + "requires": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + }, + "dependencies": { + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + } + } + }, "extglob": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", @@ -1099,6 +1372,30 @@ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, + "file-entry-cache": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", + "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", + "dev": true, + "requires": { + "flat-cache": "^2.0.1" + } + }, "fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", @@ -1153,6 +1450,23 @@ "pinkie-promise": "^2.0.0" } }, + "flat-cache": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", + "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "dev": true, + "requires": { + "flatted": "^2.0.0", + "rimraf": "2.6.3", + "write": "1.0.3" + } + }, + "flatted": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.0.tgz", + "integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==", + "dev": true + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -1684,6 +1998,12 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, "gauge": { "version": "2.7.4", "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", @@ -1762,6 +2082,12 @@ } } }, + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + }, "globule": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/globule/-/globule-1.2.1.tgz", @@ -1785,6 +2111,19 @@ "iterall": "^1.2.2" } }, + "graphql-config": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/graphql-config/-/graphql-config-2.2.1.tgz", + "integrity": "sha512-U8+1IAhw9m6WkZRRcyj8ZarK96R6lQBQ0an4lp76Ps9FyhOXENC5YQOxOFGm5CxPrX2rD0g3Je4zG5xdNJjwzQ==", + "dev": true, + "requires": { + "graphql-import": "^0.7.1", + "graphql-request": "^1.5.0", + "js-yaml": "^3.10.0", + "lodash": "^4.17.4", + "minimatch": "^3.0.4" + } + }, "graphql-import": { "version": "0.7.1", "resolved": "https://registry.npmjs.org/graphql-import/-/graphql-import-0.7.1.tgz", @@ -1794,6 +2133,15 @@ "resolve-from": "^4.0.0" } }, + "graphql-request": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/graphql-request/-/graphql-request-1.8.2.tgz", + "integrity": "sha512-dDX2M+VMsxXFCmUX0Vo0TopIZIX4ggzOtiCsThgtrKR4niiaagsGTDIHj3fsOMFETpa064vzovI+4YV4QnMbcg==", + "dev": true, + "requires": { + "cross-fetch": "2.2.2" + } + }, "har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", @@ -1910,6 +2258,28 @@ "safer-buffer": ">= 2.1.2 < 3" } }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, + "import-fresh": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.0.0.tgz", + "integrity": "sha512-pOnA9tfM3Uwics+SaBLCNyZZZbK+4PTu0OPZtLlMIrv17EdBoC15S9Kn8ckJ9TZTyKb3ywNE5y1yeDxxGA7nTQ==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, "in-publish": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/in-publish/-/in-publish-2.0.0.tgz", @@ -1973,6 +2343,79 @@ } } }, + "inquirer": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.3.1.tgz", + "integrity": "sha512-MmL624rfkFt4TG9y/Jvmt8vdmOo836U7Y0Hxr2aFk3RelZEGX4Igk0KabWrcaaZaTv9uzglOqWh1Vly+FAWAXA==", + "dev": true, + "requires": { + "ansi-escapes": "^3.2.0", + "chalk": "^2.4.2", + "cli-cursor": "^2.1.0", + "cli-width": "^2.0.0", + "external-editor": "^3.0.3", + "figures": "^2.0.0", + "lodash": "^4.17.11", + "mute-stream": "0.0.7", + "run-async": "^2.2.0", + "rxjs": "^6.4.0", + "string-width": "^2.1.0", + "strip-ansi": "^5.1.0", + "through": "^2.3.6" + }, + "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "dev": true, + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "dependencies": { + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "dev": true, + "requires": { + "ansi-regex": "^3.0.0" + } + } + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + } + } + } + } + }, "invert-kv": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", @@ -2193,6 +2636,12 @@ "resolved": "https://registry.npmjs.org/js-stringify/-/js-stringify-1.0.2.tgz", "integrity": "sha1-Fzb939lyTyijaCrcYjCufk6Weds=" }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, "js-yaml": { "version": "3.13.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", @@ -2217,6 +2666,12 @@ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, "json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", @@ -2268,6 +2723,16 @@ "invert-kv": "^1.0.0" } }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, "linkify-it": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.1.0.tgz", @@ -2436,6 +2901,12 @@ "mime-db": "1.40.0" } }, + "mimic-fn": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", + "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", + "dev": true + }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", @@ -2510,6 +2981,12 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "dev": true + }, "nan": { "version": "2.13.2", "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz", @@ -2533,11 +3010,29 @@ "to-regex": "^3.0.1" } }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, "negotiator": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, + "node-fetch": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.1.2.tgz", + "integrity": "sha1-q4hOjn5X44qUR1POxwb3iNF2i7U=", + "dev": true + }, "node-gyp": { "version": "3.8.0", "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.8.0.tgz", @@ -2727,6 +3222,37 @@ "wrappy": "1" } }, + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", + "dev": true, + "requires": { + "mimic-fn": "^1.0.0" + } + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" + }, + "dependencies": { + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + } + } + }, "os-homedir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", @@ -2759,6 +3285,15 @@ "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz", "integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ==" }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, "parse-json": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", @@ -2795,6 +3330,18 @@ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, "path-parse": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", @@ -2922,11 +3469,23 @@ "xtend": "^4.0.0" } }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true + }, "promise": { "version": "7.3.1", "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", @@ -3178,6 +3737,12 @@ "safe-regex": "^1.1.0" } }, + "regexpp": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "dev": true + }, "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", @@ -3256,6 +3821,16 @@ "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=" }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", + "dev": true, + "requires": { + "onetime": "^2.0.0", + "signal-exit": "^3.0.2" + } + }, "ret": { "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", @@ -3277,6 +3852,24 @@ "glob": "^7.1.3" } }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", + "dev": true, + "requires": { + "is-promise": "^2.1.0" + } + }, + "rxjs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.2.tgz", + "integrity": "sha512-HUb7j3kvb7p7eCUHE3FqjoDsC1xfZQ4AHFWfTKSpZ+sAhhz5X1WX0ZuUqWbzB2QhSLp3DoLUG+hMdEDKqWo2Zg==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -3440,11 +4033,45 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" }, + "slice-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "astral-regex": "^1.0.0", + "is-fullwidth-code-point": "^2.0.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + } + } + }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -3719,6 +4346,12 @@ "get-stdin": "^4.0.1" } }, + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + }, "sum-up": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sum-up/-/sum-up-1.0.3.tgz", @@ -3759,6 +4392,52 @@ "has-flag": "^3.0.0" } }, + "table": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/table/-/table-5.3.3.tgz", + "integrity": "sha512-3wUNCgdWX6PNpOe3amTTPWPuF6VGvgzjKCaO1snFj0z7Y3mUPWf5+zDtxUVGispJkDECPmR29wbzh6bVMOHbcw==", + "dev": true, + "requires": { + "ajv": "^6.9.1", + "lodash": "^4.17.11", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, "tar": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", @@ -3769,11 +4448,26 @@ "inherits": "2" } }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "requires": { + "os-tmpdir": "~1.0.2" + } + }, "to-fast-properties": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", @@ -3856,6 +4550,12 @@ "glob": "^7.1.2" } }, + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", + "dev": true + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -3869,6 +4569,15 @@ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=" }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, "type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -4059,6 +4768,12 @@ "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=" }, + "whatwg-fetch": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz", + "integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==", + "dev": true + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -4113,6 +4828,15 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, + "write": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", + "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", + "dev": true, + "requires": { + "mkdirp": "^0.5.1" + } + }, "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", diff --git a/package.json b/package.json index 27413cd..f5fc6d9 100644 --- a/package.json +++ b/package.json @@ -26,5 +26,71 @@ "node-sass": "4.12.0", "pg": "^7.11.0", "pug": "2.0.3" + }, + "devDependencies": { + "eslint": "^5.16.0", + "eslint-plugin-graphql": "^3.0.3", + "eslint-plugin-promise": "^4.1.1" + }, + "eslintConfig": { + "parserOptions": { + "ecmaVersion": 2018, + "sourceType": "module" + }, + "env": { + "node": true, + "browser": true, + "jquery": true, + "es6": true + }, + "extends": [ + "eslint:recommended", + "plugin:promise/recommended" + ], + "rules": { + "semi": "error", + "semi-style": [ + "error", + "last" + ], + "no-await-in-loop": "warn", + "curly": [ + "warn", + "multi", + "consistent" + ], + "block-spacing": [ + "warn", + "always" + ], + "array-bracket-newline": [ + "warn", + "consistent" + ], + "camelcase": [ + "error", + { + "properties": "always" + } + ], + "comma-spacing": [ + "error", + { + "after": true + } + ], + "brace-style": [ + "error", + "1tbs" + ], + "no-console": "off", + "promise/no-promise-in-callback": "off", + "promise/always-return": "off", + "promise/catch-or-return": "off" + }, + "plugins": [ + "eslint-plugin-graphql", + "eslint-plugin-promise" + ] } } diff --git a/public/javascripts/bingo-web.js b/public/javascripts/bingo-web.js index 702a4d9..0b953c6 100644 --- a/public/javascripts/bingo-web.js +++ b/public/javascripts/bingo-web.js @@ -1,3 +1,4 @@ +/* eslint-disable no-unused-vars, no-undef */ /** * Returns the value of the url-param 'game' * @returns {string} @@ -17,7 +18,7 @@ function getGameParam() { async function submitBingoWords() { let textContent = document.querySelector('#bingo-textarea').value; let words = textContent.replace(/[<>]/g, '').split('\n').filter((el) => { - return (!!el && el.length > 0) // remove empty strings and non-types from word array + return (!!el && el.length > 0); // remove empty strings and non-types from word array }); if (words.length === 0) { showError('You need to provide at least one word!'); @@ -43,7 +44,7 @@ async function submitBingoWords() { insertParam('game', gameid); } else { showError(`Failed to create game. HTTP Error: ${response.status}`); - console.error(response) + console.error(response); } } } @@ -60,7 +61,7 @@ async function createFollowup() { id } } - }`,null,`/graphql?game=${getGameParam()}`); + }`, null, `/graphql?game=${getGameParam()}`); if (response.status === 200 && response.data.bingo.createFollowupGame) { let gameid = response.data.bingo.createFollowupGame.id; insertParam('game', gameid); @@ -88,7 +89,7 @@ async function submitUsername() { } }`, { username: username - },`/graphql?game=${getGameParam()}`); + }, `/graphql?game=${getGameParam()}`); if (response.status === 200) { unameInput.value = ''; unameInput.placeholder = response.data.username; @@ -122,22 +123,59 @@ async function submitWord(word) { } }`, { word: word - },`/graphql?game=${getGameParam()}`); + }, `/graphql?game=${getGameParam()}`); if (response.status === 200 && response.data.bingo.toggleWord) { let fieldGrid = response.data.bingo.toggleWord.fieldGrid; - for (let row of fieldGrid) { - for (let field of row) { + for (let row of fieldGrid) + for (let field of row) document.querySelectorAll(`.bingo-word-panel[b-word="${field.base64Word}"]`).forEach(x => { x.setAttribute('b-sub', field.submitted); }); - } - } - if (response.data.bingo.toggleWord.bingo) { + + if (response.data.bingo.toggleWord.bingo) document.querySelector('#bingo-button').setAttribute('class', ''); - } else { + else document.querySelector('#bingo-button').setAttribute('class', 'hidden'); + + } else { + showError(`Failed to submit word. HTTP Error: ${response.status}`); + console.error(response); + } +} + +/** + * Refreshes the bingo grid. Shows the bingo button if a bingo is possible + * @returns {Promise} + */ +async function refreshBingoGrid() { + let response = await postGraphqlQuery(` + query { + bingo { + activeGrid { + bingo + fieldGrid { + word + base64Word + submitted + } } + } + }`, {}, `/graphql?game=${getGameParam()}`); + + if (response.status === 200 && response.data.bingo.activeGrid) { + let fieldGrid = response.data.bingo.activeGrid.fieldGrid; + for (let row of fieldGrid) + for (let field of row) + document.querySelectorAll(`.bingo-word-panel[b-word="${field.base64Word}"]`).forEach(x => { + x.setAttribute('b-sub', field.submitted); + }); + + if (response.data.bingo.activeGrid.bingo) + document.querySelector('#bingo-button').setAttribute('class', ''); + else + document.querySelector('#bingo-button').setAttribute('class', 'hidden'); + } else { showError(`Failed to submit word. HTTP Error: ${response.status}`); console.error(response); @@ -162,12 +200,12 @@ async function submitBingo() { } } } - }`,null,`/graphql?game=${getGameParam()}`); + }`, null, `/graphql?game=${getGameParam()}`); if (response.status === 200 && response.data.bingo.submitBingo) { let bingoSession = response.data.bingo.submitBingo; if (bingoSession.bingos.length > 0) { displayWinner(bingoSession.players.find(x => x.id === bingoSession.bingos[0]).username); - clearInterval(refrInterval) + clearInterval(refrInterval); } } else { showError(`Failed to submit Bingo. HTTP Error: ${response.status}`); @@ -181,6 +219,7 @@ async function submitBingo() { * @returns {Promise} */ async function refresh() { + await refreshBingoGrid(); let response = await postGraphqlQuery(` query { bingo { @@ -205,7 +244,7 @@ async function refresh() { if (bingoSession.bingos.length > 0) { displayWinner(bingoSession.players.find(x => x.id === bingoSession.bingos[0]).username); - clearInterval(refrInterval) + clearInterval(refrInterval); } else { for (let player of bingoSession.players) { let foundPlayerDiv = document.querySelector(`.player-container[b-pid='${player.id}'`); @@ -217,16 +256,16 @@ async function refresh() { document.querySelector('#players-container').appendChild(playerDiv); } else { let playerNameSpan = foundPlayerDiv.querySelector('.player-name-span'); - if (playerNameSpan.innerText !== player.username) { + if (playerNameSpan.innerText !== player.username) playerNameSpan.innerText = player.username; - } + } } } - for (let chatMessage of bingoSession.getMessages) { + for (let chatMessage of bingoSession.getMessages) if (!document.querySelector(`.chatMessage[msg-id='${chatMessage.id}'`)) addChatMessage(chatMessage); - } + } else { if (response.status === 400) clearInterval(refrInterval); @@ -288,7 +327,7 @@ async function sendChatMessage() { type } } - }`,{message: message}, `/graphql?game=${getGameParam()}`); + }`, {message: message}, `/graphql?game=${getGameParam()}`); if (response.status === 200) { addChatMessage(response.data.bingo.sendChatMessage); messageInput.value = ''; @@ -307,14 +346,14 @@ function addChatMessage(messageObject) { let msgSpan = document.createElement('span'); msgSpan.setAttribute('class', 'chatMessage'); msgSpan.setAttribute('msg-id', messageObject.id); - if (messageObject.type === "USER") { + if (messageObject.type === "USER") msgSpan.innerHTML = ` ${messageObject.username}: ${messageObject.htmlContent}`; - } else { + else msgSpan.innerHTML = ` ${messageObject.htmlContent}`; - } + let chatContent = document.querySelector('#chat-content'); chatContent.appendChild(msgSpan); chatContent.scrollTop = chatContent.scrollHeight; // auto-scroll to bottom @@ -338,7 +377,7 @@ function toggleChatView() { if (contentContainer.getAttribute('class') === 'displayChat') contentContainer.setAttribute('class', ''); else - contentContainer.setAttribute('class', 'displayChat') + contentContainer.setAttribute('class', 'displayChat'); } window.addEventListener("unhandledrejection", function(promiseRejectionEvent) { @@ -349,9 +388,9 @@ window.addEventListener("unhandledrejection", function(promiseRejectionEvent) { window.onload = () => { if (document.querySelector('#chat-container')) refresh(); - if (window && !document.querySelector('#bingoform')) { - refrInterval = setInterval(refresh, 1000); // global variable to clear - } + if (window && !document.querySelector('#bingoform')) + refrInterval = setInterval(refresh, 1000); // eslint-disable-line no-undef + let gridSizeElem = document.querySelector('#bingo-grid-size'); document.querySelector('#bingo-grid-y').innerText = gridSizeElem.value; gridSizeElem.oninput = () => { diff --git a/public/javascripts/common.js b/public/javascripts/common.js index 15840a7..b38cacd 100644 --- a/public/javascripts/common.js +++ b/public/javascripts/common.js @@ -1,16 +1,24 @@ +/* eslint-disable no-unused-vars, no-undef */ + +/** + * HTTP POST to an url with a post body + * @param url {String} - the url to post to + * @param postBody {JSON|Object} - the json-object to post + * @returns {Promise} + */ function postData(url, postBody) { let request = new XMLHttpRequest(); - return new Promise((res, rej) => { + return new Promise((resolve, reject) => { request.onload = () => { - res({ + resolve({ status: request.status, data: request.responseText }); }; request.onerror = () => { - rej(request.error); + reject(request.error); }; request.open('POST', url, true); @@ -19,10 +27,22 @@ function postData(url, postBody) { }); } +/** + * HTTP POST to the current url + * @param postBody {JSON|Object} - the json-object to post + * @returns {Promise} + */ async function postLocData(postBody) { return await postData('#', postBody); } +/** + * HTTP POST to a graphql url endpoint (default '/graphql') + * @param query {String} - the graphql query to post + * @param [variables] {JSON} - optional variables used in the graphql query + * @param [url] {String} - optional alternative graphql endpoint + * @returns {Promise<{data: *, status: *}|{data: *, requestBody: {variables: *, query: *}, errors: *, status: *}>} + */ async function postGraphqlQuery(query, variables, url) { let body = { query: query, @@ -31,29 +51,33 @@ async function postGraphqlQuery(query, variables, url) { let response = await postData(url || '/graphql', body); let resData = JSON.parse(response.data); - if (response.status === 200) { + if (response.status === 200) return { status: response.status, data: resData.data, }; - } else { + else return { status: response.status, data: resData.data, errors: resData.errors, requestBody: body }; - } + } +/** + * Inserts an url parameter + * @param key {String} - the key of the url parameter + * @param value {String} - the value of the url parameter + */ function insertParam(key, value) { key = encodeURI(key); value = encodeURI(value); - let kvp = document.location.search.substr(1).split('&'); - let i = kvp.length; let x; + while (i--) { x = kvp[i].split('='); @@ -63,10 +87,7 @@ function insertParam(key, value) { break; } } - - if (i < 0) { + if (i < 0) kvp[kvp.length] = [key, value].join('='); - } - document.location.search = kvp.join('&'); } diff --git a/public/javascripts/riddle-web.js b/public/javascripts/riddle-web.js index 3329b11..8921410 100644 --- a/public/javascripts/riddle-web.js +++ b/public/javascripts/riddle-web.js @@ -1,3 +1,10 @@ +/* eslint-disable no-unused-vars, no-undef */ + +/** + * start the download of a subreddit + * @param subredditName {String} - the name of the subreddit to download + * @returns {Promise} + */ async function startSubredditDownload(subredditName) { let data = await postLocData({ subreddit: subredditName @@ -5,6 +12,11 @@ async function startSubredditDownload(subredditName) { return JSON.parse(data.data); } +/** + * Get the status of a download + * @param downloadId {String} - the id of the download to get the status for + * @returns {Promise} + */ async function getDownloadStatus(downloadId) { let data = await postLocData({ id: downloadId @@ -12,6 +24,11 @@ async function getDownloadStatus(downloadId) { return JSON.parse(data.data); } +/** + * refreshes information about a specific download + * @param downloadId {String} - the id of the download + * @returns {Promise} + */ async function refreshDownloadInfo(downloadId) { let response = await getDownloadStatus(downloadId); @@ -20,7 +37,7 @@ async function refreshDownloadInfo(downloadId) { let subredditName = dlDiv.getAttribute('subreddit-name'); if (response.status === 'pending') { - setTimeout(() => refreshDownloadInfo(downloadId), 1000) + setTimeout(() => refreshDownloadInfo(downloadId), 1000); } else { let dlLink = document.createElement('a'); dlLink.setAttribute('href', response.file); @@ -34,6 +51,10 @@ async function refreshDownloadInfo(downloadId) { } } +/** + * Submit a subreddit to download (called by button) + * @returns {Promise} + */ async function submitDownload() { let subredditName = document.querySelector('#subreddit-input').value; let response = await startSubredditDownload(subredditName); diff --git a/public/stylesheets/sass/bingo/style.sass b/public/stylesheets/sass/bingo/style.sass index 88d0c3e..5a95460 100644 --- a/public/stylesheets/sass/bingo/style.sass +++ b/public/stylesheets/sass/bingo/style.sass @@ -69,6 +69,9 @@ textarea width: 100% margin: 0.5rem 0 + #chat-container .chatMessage + font-size: 1.2em + @media(min-device-width: 641px) textarea height: 80% @@ -177,7 +180,6 @@ textarea grid-row-start: 1 grid-row-end: 1 display: grid - margin: 1rem font-size: inherit button @@ -206,7 +208,7 @@ textarea grid-column-end: 1 grid-row-start: 3 grid-row-end: 4 - height: 100% + height: calc(100% - 3px) border: 1px solid $inactive margin: 0 0.5rem word-break: break-word diff --git a/public/stylesheets/sass/style.sass b/public/stylesheets/sass/style.sass index b86a1e9..16f0db6 100644 --- a/public/stylesheets/sass/style.sass +++ b/public/stylesheets/sass/style.sass @@ -57,6 +57,10 @@ textarea a color: $secondary +mark + background-color: $secondary + color: $primarySurface + ::-webkit-scrollbar width: 12px height: 12px diff --git a/routes/bingo.js b/routes/bingo.js index 8aa7808..fcf0bdf 100644 --- a/routes/bingo.js +++ b/routes/bingo.js @@ -1,7 +1,5 @@ const express = require('express'), router = express.Router(), - cproc = require('child_process'), - fsx = require('fs-extra'), mdEmoji = require('markdown-it-emoji'), mdMark = require('markdown-it-mark'), mdSmartarrows = require('markdown-it-smartarrows'), @@ -10,8 +8,6 @@ const express = require('express'), .use(mdMark) .use(mdSmartarrows); -const rWordOnly = /^\w+$/; - let bingoSessions = {}; class BingoSession { @@ -38,9 +34,9 @@ class BingoSession { addUser(user) { let id = user.id; this.users[id] = user; - if (user.username !== 'anonymous') { + if (user.username !== 'anonymous') this.chatMessages.push(new BingoChatMessage(`**${user.username}** joined.`, "INFO")); - } + } /** @@ -76,13 +72,13 @@ class BingoSession { */ getMessages(args) { let input = args.input || null; - if (input && input.id) { + if (input && input.id) return this.chatMessages.find(x => (x && x.id === input.id)); - } else if (input && input.last) { + else if (input && input.last) return this.chatMessages.slice(-input.last); - } else { + else return this.chatMessages.slice(-10); - } + } /** @@ -190,7 +186,7 @@ function inflateArray(array, minSize) { let iterations = Math.ceil(minSize/array.length)-1; for (let i = 0; i < iterations; i++) resultArray = [...resultArray, ...resultArray]; - return resultArray + return resultArray; } /** @@ -212,9 +208,9 @@ function generateWordGrid(dimensions, words) { let grid = []; for (let x = 0; x < dimensions[1]; x++) { grid[x] = []; - for (let y = 0; y < dimensions[0]; y++) { + for (let y = 0; y < dimensions[0]; y++) grid[x][y] = shuffledWords[(x * dimensions[0]) + y]; - } + } return (new BingoGrid(grid)); } @@ -235,55 +231,79 @@ function toggleHeared(base64Word, bingoGrid) { } /** - * Checks if a bingo exists in the bingo grid. - * @param bingoGrid {BingoGrid} - * @returns {boolean} + * Checks if a diagonal bingo is possible + * @param fg {Array>} - the grid with the checked (submitted) values + * @returns {boolean|boolean|*} */ -function checkBingo(bingoGrid) { - let fg = bingoGrid.fieldGrid.map(x => x.map(y => y.submitted)); - - let diagonalBingo = true; +function checkBingoDiagnoal(fg) { + let bingoCheck = true; // diagonal check for (let i = 0; i < fg.length; i++) - diagonalBingo = fg[i][i] && diagonalBingo; - if (diagonalBingo) { - bingoGrid.bingo = true; + bingoCheck = fg[i][i] && bingoCheck; + if (bingoCheck) return true; - } - diagonalBingo = true; + bingoCheck = true; for (let i = 0; i < fg.length; i++) - diagonalBingo = fg[i][fg.length - i - 1] && diagonalBingo; - if (diagonalBingo) { - bingoGrid.bingo = true; - return true; - } + bingoCheck = fg[i][fg.length - i - 1] && bingoCheck; + return bingoCheck; +} + +/** + * Checks if a vertical bingo is possible + * @param fg {Array>} - the grid with the checked (submitted) values + * @returns {boolean|boolean|*} + */ +function checkBingoVertical(fg) { let bingoCheck = true; - // horizontal check for (let row of fg) { bingoCheck = true; for (let field of row) bingoCheck = field && bingoCheck; - if (bingoCheck) { - bingoGrid.bingo = true; + if (bingoCheck) return true; - } - } - if (bingoCheck) { - bingoGrid.bingo = true; - return true; } - bingoCheck = true; + return bingoCheck; +} + +/** + * Checks if a horizontal bingo is possible + * @param fg {Array>} - the grid with the checked (submitted) values + * @returns {boolean|boolean|*} + */ +function checkBingoHorizontal(fg) { + let bingoCheck = true; // vertical check for (let i = 0; i < fg.length; i++) { bingoCheck = true; for (let j = 0; j < fg.length; j++) bingoCheck = fg[j][i] && bingoCheck; - if (bingoCheck) { - bingoGrid.bingo = true; + if (bingoCheck) return true; - } } - if (bingoCheck) { + return bingoCheck; +} + +/** + * Checks if a bingo exists in the bingo grid. + * @param bingoGrid {BingoGrid} + * @returns {boolean} + */ +function checkBingo(bingoGrid) { + let fg = bingoGrid.fieldGrid.map(x => x.map(y => y.submitted)); + let diagonalBingo = checkBingoDiagnoal(fg); + if (diagonalBingo) { + bingoGrid.bingo = true; + return true; + } + let verticalCheck = checkBingoVertical(fg); + + if (verticalCheck) { + bingoGrid.bingo = true; + return true; + } + let horizontalCheck = checkBingoHorizontal(fg); + + if (horizontalCheck) { bingoGrid.bingo = true; return true; } @@ -294,9 +314,9 @@ function checkBingo(bingoGrid) { // -- Router stuff router.use((req, res, next) => { - if (!req.session.bingoUser) { + if (!req.session.bingoUser) req.session.bingoUser = new BingoUser(); - } + next(); }); @@ -311,9 +331,9 @@ router.get('/', (req, res) => { if (!bingoSession.users[bingoUser.id]) bingoSession.addUser(bingoUser); - if (!bingoUser.grids[gameId]) { + if (!bingoUser.grids[gameId]) bingoUser.grids[gameId] = generateWordGrid([bingoSession.gridSize, bingoSession.gridSize], bingoSession.words); - } + res.render('bingo/bingo-game', { grid: bingoUser.grids[gameId].fieldGrid, username: bingoUser.username, @@ -340,7 +360,7 @@ router.graphqlResolver = (req, res) => { return bingoSession; }, checkBingo: () => { - return checkBingo(bingoUser.grids[gameId]) + return checkBingo(bingoUser.grids[gameId]); }, activeGrid: () => { return bingoUser.grids[gameId]; @@ -348,7 +368,7 @@ router.graphqlResolver = (req, res) => { // mutation createGame: ({input}) => { let words = input.words.filter((el) => { // remove empty strings and non-types from word array - return (!!el && el.length > 0) + return (!!el && el.length > 0); }); let size = input.size; if (words.length > 0 && size < 10 && size > 0) { @@ -404,14 +424,14 @@ router.graphqlResolver = (req, res) => { } }, createFollowupGame: () => { - if (bingoSession) { + if (bingoSession) if (!bingoSession.followup) return bingoSession.createFollowup(); else return bingoSessions[bingoSession.followup]; - } else { + else res.status(400); - } + }, sendChatMessage: ({input}) => { input.message = replaceTagSigns(input.message).substring(0, 250); diff --git a/routes/index.js b/routes/index.js index 6aab441..f4f0679 100644 --- a/routes/index.js +++ b/routes/index.js @@ -2,7 +2,7 @@ const express = require('express'); const router = express.Router(); /* GET home page. */ -router.get('/', function(req, res, next) { +router.get('/', function(req, res) { res.render('index', { title: 'Trivernis.net' }); }); diff --git a/routes/riddle.js b/routes/riddle.js index 6d23413..ab26927 100644 --- a/routes/riddle.js +++ b/routes/riddle.js @@ -18,10 +18,9 @@ class RedditDownload { /** * Generates an id for a subreddit download. - * @param subreddit * @returns {string} */ -function generateDownloadId(subreddit) { +function generateDownloadId() { return Date.now().toString(16); } @@ -32,7 +31,7 @@ function generateDownloadId(subreddit) { */ function startDownload(subreddit) { if (rWordOnly.test(subreddit)) { - let downloadId = generateDownloadId(subreddit); + let downloadId = generateDownloadId(); let dlFilePath = `./public/static/${downloadId}.zip`; let dlWebPath = `/static/${downloadId}.zip`; let dl = new RedditDownload(dlWebPath); @@ -40,13 +39,11 @@ function startDownload(subreddit) { dl.process = cproc.exec(`python3 -u riddle.py -o ../../public/static/${downloadId} -z --lzma ${subreddit}`, {cwd: './scripts/reddit-riddle', env: {PYTHONIOENCODING: 'utf-8', PYTHONUNBUFFERED: true}}, (err, stdout) => { - if (err) { + if (err) console.error(err); - } else { + else console.log(`riddle.py: ${stdout}`); - } }); - dl.process.on('exit', (code) => { if (code === 0) dl.status = 'finished'; @@ -57,20 +54,17 @@ function startDownload(subreddit) { delete downloads[downloadId]; }, 300000); // delete the file after 5 minutes }); - dl.process.on('message', (msg) => { - console.log(msg) + console.log(msg); }); - downloads[downloadId] = dl; - return downloadId; } } router.use('/files', express.static('./tmp')); -router.get('/', (req, res, next) => { +router.get('/', (req, res) => { res.render('riddle'); }); @@ -84,15 +78,14 @@ router.post('/', (req, res) => { let id = req.body.id; let download = downloads[id]; - if (download) { + if (download) res.send({ id: id, status: download.status, file: download.file }); - } else { + else res.send({error: 'Unknown download ID', id: id}); - } } }); diff --git a/routes/users.js b/routes/users.js index f15a20d..a05b0ad 100644 --- a/routes/users.js +++ b/routes/users.js @@ -2,8 +2,8 @@ const express = require('express'); const router = express.Router(); /* GET users listing. */ -router.get('/', function(req, res, next) { - res.send('respond with a resource'); +router.get('/', function(req, res) { + res.send('There are no users :('); }); module.exports = router;