linting, cleanup
This commit is contained in:
		
							
								
								
									
										26
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								index.js
									
									
									
									
									
								
							| @@ -9,46 +9,21 @@ | ||||
| 'use strict'; | ||||
|  | ||||
| const express = require ('express'); | ||||
| const auth = require ('@sapphirecode/auth-server-helper'); | ||||
| const body_parser = require ('body-parser'); | ||||
| const cookie_parser = require ('cookie-parser'); | ||||
| const db = require ('./lib/db'); | ||||
| const crypto = require ('@sapphirecode/crypto-helper'); | ||||
| const password_helper = require ('@sapphirecode/password-helper'); | ||||
| const api = require ('./lib/api'); | ||||
| const http_proxy = require ('express-http-proxy'); | ||||
| const history_fallback = require ('connect-history-api-fallback'); | ||||
| const fs = require ('fs'); | ||||
| const { argv } = require ('yargs'); | ||||
|  | ||||
| const salt = crypto.create_salt (); | ||||
| const hash = crypto.hash_sha512 ('asd', salt); | ||||
|  | ||||
| const user = { | ||||
|   id:       0, | ||||
|   salt, | ||||
|   password: password_helper.hash (hash) | ||||
| }; | ||||
|  | ||||
| const is_dev = argv.dev; | ||||
|  | ||||
| (async () => { | ||||
|   if (fs.existsSync ('db.sqlite')) | ||||
|     fs.unlinkSync ('db.sqlite'); | ||||
|   await db.init (is_dev); | ||||
|  | ||||
|   const app = express (); | ||||
|   app.use (cookie_parser ()); | ||||
|   app.use (body_parser.json ()); | ||||
|  | ||||
|   /* | ||||
|    * app.use (auth ((name) => { | ||||
|    *if (name === 'timo') | ||||
|    *  return user; | ||||
|    *return null; | ||||
|    *})); | ||||
|    */ | ||||
|  | ||||
|   app.use (api); | ||||
|   app.use (history_fallback ()); | ||||
|   if (is_dev) | ||||
| @@ -57,6 +32,7 @@ const is_dev = argv.dev; | ||||
|     app.use (express.static ('dist')); | ||||
|  | ||||
|   app.listen (3000, () => { | ||||
|     // eslint-disable-next-line no-console | ||||
|     console.log ('listening on 3000'); | ||||
|   }); | ||||
| }) (); | ||||
|   | ||||
| @@ -1,7 +1,10 @@ | ||||
| module.exports = (req,res,next) => { | ||||
|   console.log(req.method, req.originalUrl); | ||||
|   console.log(JSON.stringify(req.headers)); | ||||
|   console.log(''); | ||||
|   console.log(JSON.stringify(req.body, null, 2)); | ||||
|   next(); | ||||
| }; | ||||
| /* eslint-disable no-console */ | ||||
| 'use strict'; | ||||
|  | ||||
| module.exports = (req, res, next) => { | ||||
|   console.log (req.method, req.originalUrl); | ||||
|   console.log (JSON.stringify (req.headers)); | ||||
|   console.log (''); | ||||
|   console.log (JSON.stringify (req.body, null, 2)); | ||||
|   next (); | ||||
| }; | ||||
|   | ||||
| @@ -10,7 +10,7 @@ | ||||
| const router = require ('express') | ||||
|   .Router (); | ||||
|  | ||||
| router.use(require('./dump')); | ||||
| router.use (require ('./dump')); | ||||
| router.get ('/log', require ('./get-log')); | ||||
| router.get ('/app', require ('./get-app')); | ||||
|  | ||||
|   | ||||
| @@ -16,17 +16,15 @@ module.exports = async (req, res) => { | ||||
|     app_id === 'undefined' | ||||
|     || isNaN (parseInt (app_id)) | ||||
|   ) { | ||||
| 	console.log('bad request, did not receive app id'); | ||||
|     res.status (http.status_bad_request) | ||||
|       .end (); | ||||
|       .end ('app id not specified'); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   const log = req.body; | ||||
|   if (typeof log !== 'object') { | ||||
| 	console.log('bad request, did not receive data in json format'); | ||||
|     res.status (http.status_bad_request) | ||||
|       .end (); | ||||
|       .end ('invalid data format'); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -8,10 +8,16 @@ | ||||
| 'use strict'; | ||||
|  | ||||
| const knex = require ('knex'); | ||||
| const fs = require ('fs'); | ||||
|  | ||||
| let db = null; | ||||
|  | ||||
| async function init (use_fake_seed) { | ||||
|   // eslint-disable-next-line no-sync | ||||
|   if (use_fake_seed && fs.existsSync ('db.sqlite')) | ||||
|     // eslint-disable-next-line no-sync | ||||
|     fs.unlinkSync ('db.sqlite'); | ||||
|  | ||||
|   db = knex ({ | ||||
|     client:           'sqlite', | ||||
|     connection:       { filename: 'db.sqlite' }, | ||||
|   | ||||
| @@ -9,22 +9,15 @@ | ||||
|     "serve": "vue-cli-service serve" | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "@sapphirecode/auth-client-helper": "^1.1.1", | ||||
|     "@sapphirecode/auth-server-helper": "^1.1.2", | ||||
|     "@sapphirecode/consts": "^1.1.28", | ||||
|     "@sapphirecode/crypto-helper": "^1.1.57", | ||||
|     "@sapphirecode/password-helper": "^1.0.47", | ||||
|     "@sapphirecode/ui-modules": "^0.1.1", | ||||
|     "@sapphirecode/utilities": "^1.8.5", | ||||
|     "body-parser": "^1.19.0", | ||||
|     "chart.js": "^2.9.3", | ||||
|     "connect-history-api-fallback": "^1.6.0", | ||||
|     "cookie-parser": "^1.4.5", | ||||
|     "core-js": "^3.6.5", | ||||
|     "express": "^4.17.1", | ||||
|     "express-http-proxy": "^1.6.2", | ||||
|     "faker": "^4.1.0", | ||||
|     "hjson": "^3.2.1", | ||||
|     "knex": "^0.21.2", | ||||
|     "simplex-noise": "^2.4.0", | ||||
|     "sqlite3": "^5.0.0", | ||||
| @@ -53,4 +46,4 @@ | ||||
|     "name": "Timo Hocker", | ||||
|     "email": "timo@scode.ovh" | ||||
|   } | ||||
| } | ||||
| } | ||||
|   | ||||
| @@ -10,10 +10,16 @@ | ||||
| async function seed (knex) { | ||||
|   // eslint-disable-next-line no-console | ||||
|   console.log ('creating prod seeds'); | ||||
|   await knex ('app') | ||||
|     .insert ( | ||||
|       { name: 'test app' } | ||||
|     ); | ||||
|  | ||||
|   const apps = await knex ('app') | ||||
|     .select (); | ||||
|  | ||||
|   if (apps.length < 1) { | ||||
|     await knex ('app') | ||||
|       .insert ( | ||||
|         { name: 'test app' } | ||||
|       ); | ||||
|   } | ||||
| } | ||||
|  | ||||
| module.exports = { seed }; | ||||
|   | ||||
							
								
								
									
										107
									
								
								yarn.lock
									
									
									
									
									
								
							
							
						
						
									
										107
									
								
								yarn.lock
									
									
									
									
									
								
							| @@ -936,46 +936,11 @@ | ||||
|   resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b" | ||||
|   integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw== | ||||
|  | ||||
| "@phc/format@^1.0.0": | ||||
|   version "1.0.0" | ||||
|   resolved "https://registry.yarnpkg.com/@phc/format/-/format-1.0.0.tgz#b5627003b3216dc4362125b13f48a4daa76680e4" | ||||
|   integrity sha512-m7X9U6BG2+J+R1lSOdCiITLLrxm+cWlNI3HUFA92oLO77ObGNzaKdh8pMLqdZcshtkKuV84olNNXDfMc4FezBQ== | ||||
|  | ||||
| "@sapphirecode/auth-client-helper@^1.1.1": | ||||
|   version "1.1.1" | ||||
|   resolved "https://registry.yarnpkg.com/@sapphirecode/auth-client-helper/-/auth-client-helper-1.1.1.tgz#27c268007a2c392ae921fa2b5981d3257c593f85" | ||||
|   integrity sha512-D7tJV5knGIb3DdfKQI/cn3PT45tD4kzNArXyL1vLQNpkGORMj3Fs7285I/hi1Qrd7pRNFm0PcaokIV84n9lt8A== | ||||
|   dependencies: | ||||
|     "@sapphirecode/consts" "^1.1.18" | ||||
|     "@sapphirecode/crypto-helper" "^1.1.44" | ||||
|     node-fetch "^2.6.0" | ||||
|  | ||||
| "@sapphirecode/auth-server-helper@^1.1.2": | ||||
|   version "1.1.2" | ||||
|   resolved "https://registry.yarnpkg.com/@sapphirecode/auth-server-helper/-/auth-server-helper-1.1.2.tgz#9c3dd34cd55e6b771e878d0001e4b066fb9f8f6a" | ||||
|   integrity sha512-twzMZrbHut8OVVjDs9vbQEcTIl6yPAuIOsjV+eeNbX8PgBGUqmEPNcRAEYEgVthmdgtB9OH/6e+xCbn0noqBxw== | ||||
|   dependencies: | ||||
|     "@sapphirecode/consts" "^1.1.18" | ||||
|     "@sapphirecode/crypto-helper" "^1.1.44" | ||||
|     "@sapphirecode/password-helper" "^1.0.35" | ||||
|  | ||||
| "@sapphirecode/consts@^1.1.18", "@sapphirecode/consts@^1.1.28": | ||||
| "@sapphirecode/consts@^1.1.28": | ||||
|   version "1.1.28" | ||||
|   resolved "https://registry.yarnpkg.com/@sapphirecode/consts/-/consts-1.1.28.tgz#4f9400a80666c3e41b55acada999c877d32eb55c" | ||||
|   integrity sha512-OVZpkhOJtdzf379GNVPBb3D1iqTTSger8/LF/hmq9dqvrcfHm+rara2jChg9qOqk840EEzZCLEFLjyEMz+aDeA== | ||||
|  | ||||
| "@sapphirecode/crypto-helper@^1.1.44", "@sapphirecode/crypto-helper@^1.1.57": | ||||
|   version "1.1.57" | ||||
|   resolved "https://registry.yarnpkg.com/@sapphirecode/crypto-helper/-/crypto-helper-1.1.57.tgz#cfa7d7fefd417e875c2b080816b63edf699d79bf" | ||||
|   integrity sha512-ReKGCFOMq+S8y/XEY2bjG5BQFoYzoebiJi/1BYuu6WXLLTIzGO2JkZ7rsFZV2FEW1dQGVdbjpGmovMwtZjJhtw== | ||||
|   dependencies: | ||||
|     "@sapphirecode/encoding-helper" "^1.0.38" | ||||
|  | ||||
| "@sapphirecode/encoding-helper@^1.0.38": | ||||
|   version "1.0.49" | ||||
|   resolved "https://registry.yarnpkg.com/@sapphirecode/encoding-helper/-/encoding-helper-1.0.49.tgz#cb5389ff3b469910b4067b5b0487e99c55320424" | ||||
|   integrity sha512-iMgBXnXPFDuPlWJdECap+VIAwrkN0wAUK/ah4V5xJM1jmUhCHjqORv75bhkmPY+92DeusZaxBnQkC1hboeTW7A== | ||||
|  | ||||
| "@sapphirecode/eslint-config-es6@^1.1.1": | ||||
|   version "1.1.17" | ||||
|   resolved "https://registry.yarnpkg.com/@sapphirecode/eslint-config-es6/-/eslint-config-es6-1.1.17.tgz#52e554d1fa9870cc813d2a39bb84ae85f9db612d" | ||||
| @@ -1000,18 +965,6 @@ | ||||
|     eslint-plugin-node "^11.1.0" | ||||
|     eslint-plugin-sort-requires-by-path "^1.0.2" | ||||
|  | ||||
| "@sapphirecode/password-helper@^1.0.35", "@sapphirecode/password-helper@^1.0.47": | ||||
|   version "1.0.48" | ||||
|   resolved "https://registry.yarnpkg.com/@sapphirecode/password-helper/-/password-helper-1.0.48.tgz#188c374ca4c8e72826129a949aeec852fb1f4ac9" | ||||
|   integrity sha512-gHbbg+6BUivYOzDnG+21s/6TcTxN4MYVOno0De57EAu4JnuJZkYZumrz0y2U9NLDywufGKJXphvNHK/AhdcHhQ== | ||||
|   dependencies: | ||||
|     argon2 "^0.27.0" | ||||
|  | ||||
| "@sapphirecode/ui-modules@^0.1.1": | ||||
|   version "0.1.1" | ||||
|   resolved "https://registry.yarnpkg.com/@sapphirecode/ui-modules/-/ui-modules-0.1.1.tgz#97bce95999f4fa42f12a7b8af9bcd9bd940d47ee" | ||||
|   integrity sha512-yPho+ekXGjHGG9yvEcpfsZYT8jq9WwvxDHNnl962YoF8lmdVPV7NjWzYJ1cQpJWgT6GjikM4JimLp9OotrYO/w== | ||||
|  | ||||
| "@sapphirecode/utilities@^1.8.5": | ||||
|   version "1.8.5" | ||||
|   resolved "https://registry.yarnpkg.com/@sapphirecode/utilities/-/utilities-1.8.5.tgz#86bee5bd5aae2b7577ea33c39f459e9e9b35aaae" | ||||
| @@ -1783,16 +1736,6 @@ are-we-there-yet@~1.1.2: | ||||
|     delegates "^1.0.0" | ||||
|     readable-stream "^2.0.6" | ||||
|  | ||||
| argon2@^0.27.0: | ||||
|   version "0.27.0" | ||||
|   resolved "https://registry.yarnpkg.com/argon2/-/argon2-0.27.0.tgz#0e92acfab23041544208d184acf8c3ca61a67e3f" | ||||
|   integrity sha512-IkhJhz/4qaZ6RpYyRZvAMOu+EysF40z3J8jksvv0V9LvQFo13d2WBQr5lPuMzZid2k5XpdbQd2oVsgXR4Oi8TQ== | ||||
|   dependencies: | ||||
|     "@phc/format" "^1.0.0" | ||||
|     node-addon-api "^3.0.0" | ||||
|     node-pre-gyp "^0.15.0" | ||||
|     opencollective-postinstall "^2.0.3" | ||||
|  | ||||
| argparse@^1.0.7: | ||||
|   version "1.0.10" | ||||
|   resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" | ||||
| @@ -2819,14 +2762,6 @@ convert-source-map@^1.7.0: | ||||
|   dependencies: | ||||
|     safe-buffer "~5.1.1" | ||||
|  | ||||
| cookie-parser@^1.4.5: | ||||
|   version "1.4.5" | ||||
|   resolved "https://registry.yarnpkg.com/cookie-parser/-/cookie-parser-1.4.5.tgz#3e572d4b7c0c80f9c61daf604e4336831b5d1d49" | ||||
|   integrity sha512-f13bPUj/gG/5mDr+xLmSxxDsB9DQiTIfhJS/sqjrmfAWiAN+x2O4i/XguTL9yDZ+/IFDanJ+5x7hC4CXT9Tdzw== | ||||
|   dependencies: | ||||
|     cookie "0.4.0" | ||||
|     cookie-signature "1.0.6" | ||||
|  | ||||
| cookie-signature@1.0.6: | ||||
|   version "1.0.6" | ||||
|   resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" | ||||
| @@ -4670,11 +4605,6 @@ highlight.js@^9.6.0: | ||||
|   resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.3.tgz#a1a0a2028d5e3149e2380f8a865ee8516703d634" | ||||
|   integrity sha512-zBZAmhSupHIl5sITeMqIJnYCDfAEc3Gdkqj65wC1lpI468MMQeeQkhcIAvk+RylAkxrCcI9xy9piHiXeQ1BdzQ== | ||||
|  | ||||
| hjson@^3.2.1: | ||||
|   version "3.2.1" | ||||
|   resolved "https://registry.yarnpkg.com/hjson/-/hjson-3.2.1.tgz#20de41dc87fc9a10d1557d0230b0e02afb1b09ac" | ||||
|   integrity sha512-OhhrFMeC7dVuA1xvxuXGTv/yTdhTvbe8hz+3LgVNsfi9+vgz0sF/RrkuX8eegpKaMc9cwYwydImBH6iePoJtdQ== | ||||
|  | ||||
| hmac-drbg@^1.0.0: | ||||
|   version "1.0.1" | ||||
|   resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" | ||||
| @@ -6101,7 +6031,7 @@ natural-compare@^1.4.0: | ||||
|   resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" | ||||
|   integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= | ||||
|  | ||||
| needle@^2.2.1, needle@^2.5.0: | ||||
| needle@^2.2.1: | ||||
|   version "2.5.0" | ||||
|   resolved "https://registry.yarnpkg.com/needle/-/needle-2.5.0.tgz#e6fc4b3cc6c25caed7554bd613a5cf0bac8c31c0" | ||||
|   integrity sha512-o/qITSDR0JCyCKEQ1/1bnUXMmznxabbwi/Y4WwJElf+evwJNFNwIDMCCt5IigFVxgeGBJESLohGtIS9gEzo1fA== | ||||
| @@ -6137,16 +6067,6 @@ node-addon-api@2.0.0: | ||||
|   resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.0.tgz#f9afb8d777a91525244b01775ea0ddbe1125483b" | ||||
|   integrity sha512-ASCL5U13as7HhOExbT6OlWJJUV/lLzL2voOSP1UVehpRD8FbSrSDjfScK/KwAvVTI5AS6r4VwbOMlIqtvRidnA== | ||||
|  | ||||
| node-addon-api@^3.0.0: | ||||
|   version "3.0.0" | ||||
|   resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.0.0.tgz#812446a1001a54f71663bed188314bba07e09247" | ||||
|   integrity sha512-sSHCgWfJ+Lui/u+0msF3oyCgvdkhxDbkCS6Q8uiJquzOimkJBvX6hl5aSSA7DR1XbMpdM8r7phjcF63sF4rkKg== | ||||
|  | ||||
| node-fetch@^2.6.0: | ||||
|   version "2.6.0" | ||||
|   resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" | ||||
|   integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== | ||||
|  | ||||
| node-forge@0.9.0: | ||||
|   version "0.9.0" | ||||
|   resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.9.0.tgz#d624050edbb44874adca12bb9a52ec63cb782579" | ||||
| @@ -6224,22 +6144,6 @@ node-pre-gyp@^0.11.0: | ||||
|     semver "^5.3.0" | ||||
|     tar "^4" | ||||
|  | ||||
| node-pre-gyp@^0.15.0: | ||||
|   version "0.15.0" | ||||
|   resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.15.0.tgz#c2fc383276b74c7ffa842925241553e8b40f1087" | ||||
|   integrity sha512-7QcZa8/fpaU/BKenjcaeFF9hLz2+7S9AqyXFhlH/rilsQ/hPZKK32RtR5EQHJElgu+q5RfbJ34KriI79UWaorA== | ||||
|   dependencies: | ||||
|     detect-libc "^1.0.2" | ||||
|     mkdirp "^0.5.3" | ||||
|     needle "^2.5.0" | ||||
|     nopt "^4.0.1" | ||||
|     npm-packlist "^1.1.6" | ||||
|     npmlog "^4.0.2" | ||||
|     rc "^1.2.7" | ||||
|     rimraf "^2.6.1" | ||||
|     semver "^5.3.0" | ||||
|     tar "^4.4.2" | ||||
|  | ||||
| node-releases@^1.1.60: | ||||
|   version "1.1.60" | ||||
|   resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.60.tgz#6948bdfce8286f0b5d0e5a88e8384e954dfe7084" | ||||
| @@ -6516,11 +6420,6 @@ open@^6.3.0: | ||||
|   dependencies: | ||||
|     is-wsl "^1.1.0" | ||||
|  | ||||
| opencollective-postinstall@^2.0.3: | ||||
|   version "2.0.3" | ||||
|   resolved "https://registry.yarnpkg.com/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz#7a0fff978f6dbfa4d006238fbac98ed4198c3259" | ||||
|   integrity sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q== | ||||
|  | ||||
| opener@^1.5.1: | ||||
|   version "1.5.1" | ||||
|   resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.1.tgz#6d2f0e77f1a0af0032aca716c2c1fbb8e7e8abed" | ||||
| @@ -8522,7 +8421,7 @@ tar@^2.0.0: | ||||
|     fstream "^1.0.12" | ||||
|     inherits "2" | ||||
|  | ||||
| tar@^4, tar@^4.4.2: | ||||
| tar@^4: | ||||
|   version "4.4.13" | ||||
|   resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.13.tgz#43b364bc52888d555298637b10d60790254ab525" | ||||
|   integrity sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA== | ||||
|   | ||||
		Reference in New Issue
	
	Block a user