Switched to express-busboy, dropping Multer (yay!) (#90)

pull/62/head
Josh Moore 3 years ago committed by GitHub
parent 0fd12f5504
commit bb0729dc21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -76,13 +76,13 @@ app.get('/', (req, res, next) => ASS_INDEX_ENABLED // skipcq: JS-0229
.then((d) => res.render('index', { data: d }))
.catch(next));
// Upload router
app.use('/', ROUTERS.upload);
// Set up custom frontend
const ASS_FRONTEND = fs.existsSync(`./${frontendName}/package.json`) ? (require('submodule'), require(`./${frontendName}`)) : { enabled: false };
ASS_FRONTEND.enabled && app.use(ASS_FRONTEND.endpoint, ASS_FRONTEND.router); // skipcq: JS-0093
// Upload router (has to come after custom frontends as express-busboy interferes with all POST calls)
app.use('/', ROUTERS.upload);
// '/:resouceId' always needs to be LAST since it's a catch-all route
app.use('/:resourceId', (req, _res, next) => (req.resourceId = req.params.resourceId, next()), ROUTERS.resource); // skipcq: JS-0086, JS-0090

456
package-lock.json generated

@ -20,6 +20,7 @@
"discord-webhook-node": "^1.1.8",
"escape-html": "^1.0.3",
"express": "^4.17.1",
"express-busboy": "^8.0.0",
"express-rate-limit": "^5.2.6",
"ffmpeg-static": "^4.3.0",
"fs-extra": "^9.1.0",
@ -27,7 +28,6 @@
"jimp": "^0.16.1",
"luxon": "^1.26.0",
"marked": "^2.0.7",
"multer": "2.0.0-rc.2",
"node-fetch": "^2.6.1",
"node-vibrant": "*",
"prompt": "^1.1.0",
@ -55,9 +55,9 @@
}
},
"node_modules/@babel/parser": {
"version": "7.15.7",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.15.7.tgz",
"integrity": "sha512-rycZXvQ+xS9QyIcJ9HXeDWf1uxqlbVFAUq0Rq0dbc50Zb/+wUe/ehyfzGfm9KZZF0kBejYgxltBXocP+gKdL2g==",
"version": "7.15.8",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.15.8.tgz",
"integrity": "sha512-BRYa3wcQnjS/nqI8Ac94pYYpJfojHVvVXJ97+IDCImX4Jc8W8Xv1+47enbruk+q1etOpsQNwnfFcNGw+gtPGxA==",
"bin": {
"parser": "bin/babel-parser.js"
},
@ -835,11 +835,6 @@
"resolved": "https://registry.npmjs.org/any-shell-escape/-/any-shell-escape-0.1.1.tgz",
"integrity": "sha1-1Vq5ciRMcaml4asIefML8RCAaVk="
},
"node_modules/append-field": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz",
"integrity": "sha1-HjRA6RXwsSA9I3SOeO3XubW0PlY="
},
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
@ -874,9 +869,9 @@
}
},
"node_modules/aws-sdk": {
"version": "2.999.0",
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.999.0.tgz",
"integrity": "sha512-OcnD7m+HCZv2qDzmS7TgABGf26mVPfIyah0Dgz7hHAxBtx78qFWi/s9U6BDxVBKWLg7OKWVHf0opiMG4ujteqg==",
"version": "2.1006.0",
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1006.0.tgz",
"integrity": "sha512-lwXAy706+1HVQqMnHaahdeBZZbdu6TWrtTY0ydeG0qanwldTFNMLczwnETTZWYsqNAU+wjl1VzmFdMO4gePLNQ==",
"hasInstallScript": true,
"dependencies": {
"buffer": "4.9.2",
@ -913,14 +908,6 @@
"node": ">= 10.0.0"
}
},
"node_modules/base32-encode": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/base32-encode/-/base32-encode-1.2.0.tgz",
"integrity": "sha512-cHFU8XeRyx0GgmoWi5qHMCVRiqU6J3MHWxVgun7jggCBUpVzm1Ir7M9dYr2whjSNc3tFeXfQ/oZjQu/4u55h9A==",
"dependencies": {
"to-data-view": "^1.1.0"
}
},
"node_modules/base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
@ -945,6 +932,17 @@
"resolved": "https://registry.npmjs.org/bmp-js/-/bmp-js-0.1.0.tgz",
"integrity": "sha1-4Fpj95amwf8l9Hcex62twUjAcjM="
},
"node_modules/body": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/body/-/body-5.1.0.tgz",
"integrity": "sha1-5LoM5BCkaTYyM2dgnstOZVMSUGk=",
"dependencies": {
"continuable-cache": "^0.3.1",
"error": "^7.0.0",
"raw-body": "~1.1.0",
"safe-json-parse": "~1.0.1"
}
},
"node_modules/body-parser": {
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
@ -965,6 +963,28 @@
"node": ">= 0.8"
}
},
"node_modules/body/node_modules/bytes": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-1.0.0.tgz",
"integrity": "sha1-NWnt6Lo0MV+rmcPpLLBMciDeH6g="
},
"node_modules/body/node_modules/raw-body": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-1.1.7.tgz",
"integrity": "sha1-HQJ8K/oRasxmI7yo8AAWVyqH1CU=",
"dependencies": {
"bytes": "1",
"string_decoder": "0.10"
},
"engines": {
"node": ">= 0.8.0"
}
},
"node_modules/body/node_modules/string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
},
"node_modules/boxen": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/boxen/-/boxen-4.2.0.tgz",
@ -1304,6 +1324,17 @@
"typedarray": "^0.0.6"
}
},
"node_modules/connect-busboy": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/connect-busboy/-/connect-busboy-0.0.2.tgz",
"integrity": "sha1-rFyclmchcYheV2xmsr/ZXTuxEJc=",
"dependencies": {
"busboy": "*"
},
"engines": {
"node": ">=0.8.0"
}
},
"node_modules/constantinople": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/constantinople/-/constantinople-4.0.1.tgz",
@ -1332,6 +1363,11 @@
"node": ">= 0.6"
}
},
"node_modules/continuable-cache": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/continuable-cache/-/continuable-cache-0.3.1.tgz",
"integrity": "sha1-vXJ6f67XfnH/OYWskzUakSczrQ8="
},
"node_modules/cookie": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
@ -1477,11 +1513,6 @@
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="
},
"node_modules/encode-utf8": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-1.0.3.tgz",
"integrity": "sha512-ucAnuBEhUK4boH2HjVYG5Q2mQyPorvv0u/ocS+zhdw0S8AlHYY+GOFhP1Gio5z4icpP2ivFSvhtFjQi8+T9ppw=="
},
"node_modules/encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
@ -1506,6 +1537,14 @@
"node": ">=6"
}
},
"node_modules/error": {
"version": "7.2.1",
"resolved": "https://registry.npmjs.org/error/-/error-7.2.1.tgz",
"integrity": "sha512-fo9HBvWnx3NGUKMvMwB/CBCMMrfEJgbDTVDEkPygA3Bdd3lM1OyCd+rbQ8BwnpF6GdVeOLDNmyL4N5Bg80ZvdA==",
"dependencies": {
"string-template": "~0.2.1"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
@ -1597,10 +1636,28 @@
"node": ">= 0.10.0"
}
},
"node_modules/express-busboy": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/express-busboy/-/express-busboy-8.0.0.tgz",
"integrity": "sha512-BrNjpjio/A3mr1P83ZwvYK+7ClJC98KHN9io+ybo58Gx2mO7TDFR/Ol1uwR/dWOAWzIFT3OnSxq1m0PFIvDo/w==",
"dependencies": {
"body": "~5.1.0",
"connect-busboy": "~0.0.1",
"mkdirp": "~0.5.0",
"qs": "^6.4.0",
"uuid": "~1.4.1"
}
},
"node_modules/express-busboy/node_modules/uuid": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-1.4.2.tgz",
"integrity": "sha1-RTAZ9oaWam34PNxSROfJkOzDMvw=",
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details."
},
"node_modules/express-rate-limit": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.4.0.tgz",
"integrity": "sha512-sT+rk1wvj06+0MpEiij7y3kGdB4hoMyQ+a5zcESUpDMLhbLXoYIQI6JfsvLBz1wOhmfF//ALG/Q59FKMI0x2Eg=="
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.5.0.tgz",
"integrity": "sha512-/1mrKggjXMxd1/ghPub5N3d36u5VlK8KjbQFQLxYub09BWSSgSXMQbXgFiIW0BYxjM49YCj8bkihONZR2U4+mQ=="
},
"node_modules/eyes": {
"version": "0.1.8",
@ -1661,14 +1718,6 @@
"node": ">=6"
}
},
"node_modules/fmix": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/fmix/-/fmix-0.1.0.tgz",
"integrity": "sha1-x7vxJN7ELJ0ZHPuUfQqXeN2YbAw=",
"dependencies": {
"imul": "^1.0.0"
}
},
"node_modules/form-data": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz",
@ -1712,14 +1761,6 @@
"node": ">=10"
}
},
"node_modules/fs-temp": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/fs-temp/-/fs-temp-1.2.1.tgz",
"integrity": "sha512-okTwLB7/Qsq82G6iN5zZJFsOfZtx2/pqrA7Hk/9fvy+c+eJS9CvgGXT2uNxwnI14BDY9L/jQPkaBgSvlKfSW9w==",
"dependencies": {
"random-path": "^0.1.0"
}
},
"node_modules/function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
@ -1796,11 +1837,6 @@
"node": ">=8"
}
},
"node_modules/has-own-property": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/has-own-property/-/has-own-property-1.0.0.tgz",
"integrity": "sha1-PpjMHStfPagNPq/SjMZfyt2pZdo="
},
"node_modules/has-symbols": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz",
@ -1919,14 +1955,6 @@
"node": ">=0.9.0"
}
},
"node_modules/imul": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/imul/-/imul-1.0.1.tgz",
"integrity": "sha1-nVhnFh6LPelsLDjV3HyxAvNeKsk=",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
@ -2248,36 +2276,6 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"node_modules/multer": {
"version": "2.0.0-rc.2",
"resolved": "https://registry.npmjs.org/multer/-/multer-2.0.0-rc.2.tgz",
"integrity": "sha512-IjQe1wZoANXrZ0A7cED1dxUny3BFezp6jajZ2FDjP6Rjfxib20WPbWYIPe2mjq0enipuIqz7XLdAkbqO6+oqzQ==",
"dependencies": {
"append-field": "^1.0.0",
"busboy": "^0.3.1",
"bytes": "^3.1.0",
"fs-temp": "^1.1.1",
"has-own-property": "^1.0.0",
"on-finished": "^2.3.0",
"pify": "^5.0.0",
"pump": "^3.0.0",
"stream-file-type": "^0.4.0",
"type-is": "^1.6.18"
},
"engines": {
"node": ">=10.13"
}
},
"node_modules/murmur-32": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/murmur-32/-/murmur-32-0.2.0.tgz",
"integrity": "sha512-ZkcWZudylwF+ir3Ld1n7gL6bI2mQAzXvSobPwVtu8aYi2sbXeipeSkdcanRLzIofLcM5F53lGaKm2dk7orBi7Q==",
"dependencies": {
"encode-utf8": "^1.0.3",
"fmix": "^0.1.0",
"imul": "^1.0.0"
}
},
"node_modules/mute-stream": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz",
@ -2529,17 +2527,6 @@
"resolved": "https://registry.npmjs.org/phin/-/phin-2.9.3.tgz",
"integrity": "sha512-CzFr90qM24ju5f88quFC/6qohjC144rehe5n6DH900lgXmUe86+xCKc10ev56gRKC4/BkHUoG4uSiQgBiIXwDA=="
},
"node_modules/pify": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-5.0.0.tgz",
"integrity": "sha512-eW/gHNMlxdSP6dmG6uJip6FXN0EQBwm2clYYd8Wul42Cwu/DK8HEftzsapcNdYe2MfLiIwZqsDk2RDEsTE79hA==",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/pixelmatch": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-4.0.2.tgz",
@ -2777,15 +2764,6 @@
}
]
},
"node_modules/random-path": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/random-path/-/random-path-0.1.2.tgz",
"integrity": "sha512-4jY0yoEaQ5v9StCl5kZbNIQlg1QheIDBrdkDn53EynpPb9FgO6//p3X/tgMnrC45XN6QZCzU1Xz/+pSSsJBpRw==",
"dependencies": {
"base32-encode": "^0.1.0 || ^1.0.0",
"murmur-32": "^0.1.0 || ^0.2.0"
}
},
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
@ -2903,6 +2881,11 @@
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"node_modules/safe-json-parse": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/safe-json-parse/-/safe-json-parse-1.0.1.tgz",
"integrity": "sha1-PnZyPjjf3aE8mx0poeB//uSzC1c="
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
@ -3021,39 +3004,6 @@
"node": ">= 0.6"
}
},
"node_modules/stream-file-type": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/stream-file-type/-/stream-file-type-0.4.0.tgz",
"integrity": "sha512-Nj1pls0XYICU1yWqH1Qi4le/IY8b8vMtW9z4Jk0G/Fd/5p851w/kLXW94Lbv/r4CZA2eXIj4/EHNTaPnUxT8Og==",
"dependencies": {
"file-type": "^12.0.0",
"readable-stream": "^3.0.6"
},
"engines": {
"node": ">=8"
}
},
"node_modules/stream-file-type/node_modules/file-type": {
"version": "12.4.2",
"resolved": "https://registry.npmjs.org/file-type/-/file-type-12.4.2.tgz",
"integrity": "sha512-UssQP5ZgIOKelfsaB5CuGAL+Y+q7EmONuiwF3N5HAH0t27rvrttgi6Ra9k/+DVaY9UF6+ybxu5pOXLUdA8N7Vg==",
"engines": {
"node": ">=8"
}
},
"node_modules/stream-file-type/node_modules/readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
"dependencies": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/stream-to-array": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/stream-to-array/-/stream-to-array-2.3.0.tgz",
@ -3078,6 +3028,11 @@
"safe-buffer": "~5.1.0"
}
},
"node_modules/string-template": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/string-template/-/string-template-0.2.1.tgz",
"integrity": "sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0="
},
"node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
@ -3180,11 +3135,6 @@
"node": "*"
}
},
"node_modules/to-data-view": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/to-data-view/-/to-data-view-1.1.0.tgz",
"integrity": "sha512-1eAdufMg6mwgmlojAx3QeMnzB/BTVp7Tbndi3U7ftcT2zCZadjxkkmLmd97zmaxWi+sgGcgWrokmpEoy0Dn0vQ=="
},
"node_modules/to-fast-properties": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
@ -3596,9 +3546,9 @@
"integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w=="
},
"@babel/parser": {
"version": "7.15.7",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.15.7.tgz",
"integrity": "sha512-rycZXvQ+xS9QyIcJ9HXeDWf1uxqlbVFAUq0Rq0dbc50Zb/+wUe/ehyfzGfm9KZZF0kBejYgxltBXocP+gKdL2g=="
"version": "7.15.8",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.15.8.tgz",
"integrity": "sha512-BRYa3wcQnjS/nqI8Ac94pYYpJfojHVvVXJ97+IDCImX4Jc8W8Xv1+47enbruk+q1etOpsQNwnfFcNGw+gtPGxA=="
},
"@babel/runtime": {
"version": "7.15.4",
@ -4191,11 +4141,6 @@
"resolved": "https://registry.npmjs.org/any-shell-escape/-/any-shell-escape-0.1.1.tgz",
"integrity": "sha1-1Vq5ciRMcaml4asIefML8RCAaVk="
},
"append-field": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz",
"integrity": "sha1-HjRA6RXwsSA9I3SOeO3XubW0PlY="
},
"array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
@ -4227,9 +4172,9 @@
"integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg=="
},
"aws-sdk": {
"version": "2.999.0",
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.999.0.tgz",
"integrity": "sha512-OcnD7m+HCZv2qDzmS7TgABGf26mVPfIyah0Dgz7hHAxBtx78qFWi/s9U6BDxVBKWLg7OKWVHf0opiMG4ujteqg==",
"version": "2.1006.0",
"resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1006.0.tgz",
"integrity": "sha512-lwXAy706+1HVQqMnHaahdeBZZbdu6TWrtTY0ydeG0qanwldTFNMLczwnETTZWYsqNAU+wjl1VzmFdMO4gePLNQ==",
"requires": {
"buffer": "4.9.2",
"events": "1.1.1",
@ -4257,14 +4202,6 @@
"@babel/types": "^7.9.6"
}
},
"base32-encode": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/base32-encode/-/base32-encode-1.2.0.tgz",
"integrity": "sha512-cHFU8XeRyx0GgmoWi5qHMCVRiqU6J3MHWxVgun7jggCBUpVzm1Ir7M9dYr2whjSNc3tFeXfQ/oZjQu/4u55h9A==",
"requires": {
"to-data-view": "^1.1.0"
}
},
"base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
@ -4275,6 +4212,38 @@
"resolved": "https://registry.npmjs.org/bmp-js/-/bmp-js-0.1.0.tgz",
"integrity": "sha1-4Fpj95amwf8l9Hcex62twUjAcjM="
},
"body": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/body/-/body-5.1.0.tgz",
"integrity": "sha1-5LoM5BCkaTYyM2dgnstOZVMSUGk=",
"requires": {
"continuable-cache": "^0.3.1",
"error": "^7.0.0",
"raw-body": "~1.1.0",
"safe-json-parse": "~1.0.1"
},
"dependencies": {
"bytes": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-1.0.0.tgz",
"integrity": "sha1-NWnt6Lo0MV+rmcPpLLBMciDeH6g="
},
"raw-body": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-1.1.7.tgz",
"integrity": "sha1-HQJ8K/oRasxmI7yo8AAWVyqH1CU=",
"requires": {
"bytes": "1",
"string_decoder": "0.10"
}
},
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ="
}
}
},
"body-parser": {
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
@ -4555,6 +4524,14 @@
"typedarray": "^0.0.6"
}
},
"connect-busboy": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/connect-busboy/-/connect-busboy-0.0.2.tgz",
"integrity": "sha1-rFyclmchcYheV2xmsr/ZXTuxEJc=",
"requires": {
"busboy": "*"
}
},
"constantinople": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/constantinople/-/constantinople-4.0.1.tgz",
@ -4577,6 +4554,11 @@
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
"integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="
},
"continuable-cache": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/continuable-cache/-/continuable-cache-0.3.1.tgz",
"integrity": "sha1-vXJ6f67XfnH/OYWskzUakSczrQ8="
},
"cookie": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
@ -4694,11 +4676,6 @@
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A=="
},
"encode-utf8": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/encode-utf8/-/encode-utf8-1.0.3.tgz",
"integrity": "sha512-ucAnuBEhUK4boH2HjVYG5Q2mQyPorvv0u/ocS+zhdw0S8AlHYY+GOFhP1Gio5z4icpP2ivFSvhtFjQi8+T9ppw=="
},
"encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
@ -4717,6 +4694,14 @@
"resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz",
"integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A=="
},
"error": {
"version": "7.2.1",
"resolved": "https://registry.npmjs.org/error/-/error-7.2.1.tgz",
"integrity": "sha512-fo9HBvWnx3NGUKMvMwB/CBCMMrfEJgbDTVDEkPygA3Bdd3lM1OyCd+rbQ8BwnpF6GdVeOLDNmyL4N5Bg80ZvdA==",
"requires": {
"string-template": "~0.2.1"
}
},
"escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
@ -4793,10 +4778,29 @@
"vary": "~1.1.2"
}
},
"express-busboy": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/express-busboy/-/express-busboy-8.0.0.tgz",
"integrity": "sha512-BrNjpjio/A3mr1P83ZwvYK+7ClJC98KHN9io+ybo58Gx2mO7TDFR/Ol1uwR/dWOAWzIFT3OnSxq1m0PFIvDo/w==",
"requires": {
"body": "~5.1.0",
"connect-busboy": "~0.0.1",
"mkdirp": "~0.5.0",
"qs": "^6.4.0",
"uuid": "~1.4.1"
},
"dependencies": {
"uuid": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-1.4.2.tgz",
"integrity": "sha1-RTAZ9oaWam34PNxSROfJkOzDMvw="
}
}
},
"express-rate-limit": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.4.0.tgz",
"integrity": "sha512-sT+rk1wvj06+0MpEiij7y3kGdB4hoMyQ+a5zcESUpDMLhbLXoYIQI6JfsvLBz1wOhmfF//ALG/Q59FKMI0x2Eg=="
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-5.5.0.tgz",
"integrity": "sha512-/1mrKggjXMxd1/ghPub5N3d36u5VlK8KjbQFQLxYub09BWSSgSXMQbXgFiIW0BYxjM49YCj8bkihONZR2U4+mQ=="
},
"eyes": {
"version": "0.1.8",
@ -4841,14 +4845,6 @@
"locate-path": "^3.0.0"
}
},
"fmix": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/fmix/-/fmix-0.1.0.tgz",
"integrity": "sha1-x7vxJN7ELJ0ZHPuUfQqXeN2YbAw=",
"requires": {
"imul": "^1.0.0"
}
},
"form-data": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz",
@ -4880,14 +4876,6 @@
"universalify": "^2.0.0"
}
},
"fs-temp": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/fs-temp/-/fs-temp-1.2.1.tgz",
"integrity": "sha512-okTwLB7/Qsq82G6iN5zZJFsOfZtx2/pqrA7Hk/9fvy+c+eJS9CvgGXT2uNxwnI14BDY9L/jQPkaBgSvlKfSW9w==",
"requires": {
"random-path": "^0.1.0"
}
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
@ -4952,11 +4940,6 @@
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
},
"has-own-property": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/has-own-property/-/has-own-property-1.0.0.tgz",
"integrity": "sha1-PpjMHStfPagNPq/SjMZfyt2pZdo="
},
"has-symbols": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz",
@ -5044,11 +5027,6 @@
"resolved": "https://registry.npmjs.org/image-q/-/image-q-1.1.1.tgz",
"integrity": "sha1-/IQJlmRGC5DKhi2TALa/u7+/gFY="
},
"imul": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/imul/-/imul-1.0.1.tgz",
"integrity": "sha1-nVhnFh6LPelsLDjV3HyxAvNeKsk="
},
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
@ -5299,33 +5277,6 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"multer": {
"version": "2.0.0-rc.2",
"resolved": "https://registry.npmjs.org/multer/-/multer-2.0.0-rc.2.tgz",
"integrity": "sha512-IjQe1wZoANXrZ0A7cED1dxUny3BFezp6jajZ2FDjP6Rjfxib20WPbWYIPe2mjq0enipuIqz7XLdAkbqO6+oqzQ==",
"requires": {
"append-field": "^1.0.0",
"busboy": "^0.3.1",
"bytes": "^3.1.0",
"fs-temp": "^1.1.1",
"has-own-property": "^1.0.0",
"on-finished": "^2.3.0",
"pify": "^5.0.0",
"pump": "^3.0.0",
"stream-file-type": "^0.4.0",
"type-is": "^1.6.18"
}
},
"murmur-32": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/murmur-32/-/murmur-32-0.2.0.tgz",
"integrity": "sha512-ZkcWZudylwF+ir3Ld1n7gL6bI2mQAzXvSobPwVtu8aYi2sbXeipeSkdcanRLzIofLcM5F53lGaKm2dk7orBi7Q==",
"requires": {
"encode-utf8": "^1.0.3",
"fmix": "^0.1.0",
"imul": "^1.0.0"
}
},
"mute-stream": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz",
@ -5528,11 +5479,6 @@
"resolved": "https://registry.npmjs.org/phin/-/phin-2.9.3.tgz",
"integrity": "sha512-CzFr90qM24ju5f88quFC/6qohjC144rehe5n6DH900lgXmUe86+xCKc10ev56gRKC4/BkHUoG4uSiQgBiIXwDA=="
},
"pify": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-5.0.0.tgz",
"integrity": "sha512-eW/gHNMlxdSP6dmG6uJip6FXN0EQBwm2clYYd8Wul42Cwu/DK8HEftzsapcNdYe2MfLiIwZqsDk2RDEsTE79hA=="
},
"pixelmatch": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-4.0.2.tgz",
@ -5731,15 +5677,6 @@
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
"integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="
},
"random-path": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/random-path/-/random-path-0.1.2.tgz",
"integrity": "sha512-4jY0yoEaQ5v9StCl5kZbNIQlg1QheIDBrdkDn53EynpPb9FgO6//p3X/tgMnrC45XN6QZCzU1Xz/+pSSsJBpRw==",
"requires": {
"base32-encode": "^0.1.0 || ^1.0.0",
"murmur-32": "^0.1.0 || ^0.2.0"
}
},
"range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
@ -5825,6 +5762,11 @@
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"safe-json-parse": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/safe-json-parse/-/safe-json-parse-1.0.1.tgz",
"integrity": "sha1-PnZyPjjf3aE8mx0poeB//uSzC1c="
},
"safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
@ -5924,32 +5866,6 @@
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
},
"stream-file-type": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/stream-file-type/-/stream-file-type-0.4.0.tgz",
"integrity": "sha512-Nj1pls0XYICU1yWqH1Qi4le/IY8b8vMtW9z4Jk0G/Fd/5p851w/kLXW94Lbv/r4CZA2eXIj4/EHNTaPnUxT8Og==",
"requires": {
"file-type": "^12.0.0",
"readable-stream": "^3.0.6"
},
"dependencies": {
"file-type": {
"version": "12.4.2",
"resolved": "https://registry.npmjs.org/file-type/-/file-type-12.4.2.tgz",
"integrity": "sha512-UssQP5ZgIOKelfsaB5CuGAL+Y+q7EmONuiwF3N5HAH0t27rvrttgi6Ra9k/+DVaY9UF6+ybxu5pOXLUdA8N7Vg=="
},
"readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
}
}
}
},
"stream-to-array": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/stream-to-array/-/stream-to-array-2.3.0.tgz",
@ -5971,6 +5887,11 @@
"safe-buffer": "~5.1.0"
}
},
"string-template": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/string-template/-/string-template-0.2.1.tgz",
"integrity": "sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0="
},
"string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
@ -6043,11 +5964,6 @@
"resolved": "https://registry.npmjs.org/tinycolor2/-/tinycolor2-1.4.2.tgz",
"integrity": "sha512-vJhccZPs965sV/L2sU4oRQVAos0pQXwsvTLkWYdqJ+a8Q5kPFzJTuOFwy7UniPli44NKQGAglksjvOcpo95aZA=="
},
"to-data-view": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/to-data-view/-/to-data-view-1.1.0.tgz",
"integrity": "sha512-1eAdufMg6mwgmlojAx3QeMnzB/BTVp7Tbndi3U7ftcT2zCZadjxkkmLmd97zmaxWi+sgGcgWrokmpEoy0Dn0vQ=="
},
"to-fast-properties": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",

@ -46,6 +46,7 @@
"discord-webhook-node": "^1.1.8",
"escape-html": "^1.0.3",
"express": "^4.17.1",
"express-busboy": "^8.0.0",
"express-rate-limit": "^5.2.6",
"ffmpeg-static": "^4.3.0",
"fs-extra": "^9.1.0",
@ -53,7 +54,6 @@
"jimp": "^0.16.1",
"luxon": "^1.26.0",
"marked": "^2.0.7",
"multer": "2.0.0-rc.2",
"node-fetch": "^2.6.1",
"node-vibrant": "*",
"prompt": "^1.1.0",

@ -1,8 +1,9 @@
const fs = require('fs-extra');
const bb = require('express-busboy');
//const rateLimit = require('express-rate-limit');
const { DateTime } = require('luxon');
const { Webhook, MessageBuilder } = require('discord-webhook-node');
const { doUpload, processUploaded } = require('../storage');
const { processUploaded } = require('../storage');
const { maxUploadSize, resourceIdSize, gfyIdSize, resourceIdType, spaceReplace } = require('../config.json');
const { path, log, verify, getTrueHttp, getTrueDomain, generateId, formatBytes } = require('../utils');
const { CODE_UNAUTHORIZED, CODE_PAYLOAD_TOO_LARGE } = require('../MagicNumbers.json');
@ -13,6 +14,13 @@ const ASS_LOGO = 'https://cdn.discordapp.com/icons/848274994375294986/8d339d4a2f
const express = require('express');
const router = express.Router();
// Set up express-busboy
bb.extend(router, {
upload: true,
restrictMultiple: true,
allowedPath: (url) => url === '/',
});
// Rate limit middleware
/* router.use('/', rateLimit({
windowMs: 1000 * 60, // 60 seconds // skipcq: JS-0074
@ -27,13 +35,10 @@ router.post('/', (req, res, next) => {
});
// Upload file
//router.post('/', doUpload, processUploaded, ({ next }) => next());
router.post('/', (req, res, next) => doUpload(req, res, (err) => {
log.express().Header(req, 'Content-Type');
(err) ? log.error(`Multer encountered an ${!(err.toString().includes('MulterError')) ? 'unknown ' : ''}error`, err).callback(next, err) : log.debug('Multer', 'File saved in temp dir').callback(next);
}), processUploaded, ({ next }) => next());
router.post('/', processUploaded);
router.use('/', (err, _req, res, next) => err.code && err.code === 'LIMIT_FILE_SIZE' ? log.warn('Upload blocked', 'File too large').callback(() => res.status(CODE_PAYLOAD_TOO_LARGE).send(`Max upload size: ${maxUploadSize}MB`)) : next(err)); // skipcq: JS-0229
// Max upload size error handling
router.use('/', (err, _req, res, next) => err.message === 'LIMIT_FILE_SIZE' ? log.warn('Upload blocked', 'File too large').callback(() => res.status(CODE_PAYLOAD_TOO_LARGE).send(`Max upload size: ${maxUploadSize}MB`)) : next(err)); // skipcq: JS-0229
// Process uploaded file
router.post('/', (req, res, next) => {

@ -3,12 +3,11 @@
const fs = require('fs-extra');
const aws = require('aws-sdk');
const multer = require('multer');
const Thumbnail = require('./thumbnails');
const Vibrant = require('./vibrant');
const Hash = require('./hash');
const { getDatedDirname, sanitize, generateId, formatBytes, log } = require('./utils');
const { s3enabled, s3endpoint, s3bucket, s3usePathStyle, s3accessKey, s3secretKey, saveAsOriginal, maxUploadSize, mediaStrict } = require('./config.json');
const { getDatedDirname, generateId, log } = require('./utils');
const { s3enabled, s3endpoint, s3bucket, s3usePathStyle, s3accessKey, s3secretKey, saveAsOriginal, mediaStrict, maxUploadSize } = require('./config.json');
const { CODE_UNSUPPORTED_MEDIA_TYPE } = require('./MagicNumbers.json');
const ID_GEN_LENGTH = 32;
@ -20,25 +19,18 @@ const s3 = new aws.S3({
credentials: new aws.Credentials({ accessKeyId: s3accessKey, secretAccessKey: s3secretKey })
});
function saveFile(req) {
log.null(req.file, 'Unable to save req.file!')
.debug('Temp file saving');
return new Promise((resolve, reject) =>
fs.ensureDir(getDatedDirname())
.then(() => fs.createWriteStream(req.file.path.concat('.temp')))
.then((stream) => req.file.stream.pipe(stream).on('finish', () => log.debug('Temp file saved', req.file.path, formatBytes(req.file.size)).callback(resolve)).on('error', reject))
.catch(reject));
}
function getLocalFilename(req) {
return `${getDatedDirname()}/${saveAsOriginal ? req.file.originalname : req.file.sha1}`;
}
function processUploaded(req, res, next) {
// Fixes
req.file.mimetype = req.file.detectedMimeType || req.file.clientReportedMimeType;
req.file.ext = req.file.detectedFileExtension || req.file.clientReportedFileExtension;
req.file.originalname = sanitize(req.file.originalName);
function processUploaded(req, res, next) { // skipcq: JS-0045
// Fix file object
req.file = req.files.file;
// Other fixes
req.file.ext = '.'.concat(req.file.filename.split('.').pop());
req.file.originalname = req.file.filename;
req.file.path = req.file.file;
req.file.randomId = generateId('random', ID_GEN_LENGTH, null, null);
req.file.deleteId = generateId('random', ID_GEN_LENGTH, null, null);
@ -55,39 +47,41 @@ function processUploaded(req, res, next) {
req.file.is[isType] = true;
// Block the resource if the mimetype is not an image or video
if (mediaStrict && !ALLOWED_MIMETYPES.test(req.file.mimetype)) {
if (mediaStrict && !ALLOWED_MIMETYPES.test(req.file.mimetype))
return log
.warn('Upload blocked', req.file.originalname, req.file.mimetype)
.warn('Strict media mode', 'only images, videos, & audio are file permitted')
.callback(() =>
fs.remove(req.file.path.concat('.temp'))
fs.remove(req.file.path)
.then(() => log
.debug('Temp file', 'deleted')
.callback(() => res.sendStatus(CODE_UNSUPPORTED_MEDIA_TYPE)))
.catch((err) => log
.error('Temp file could not be deleted', err)
.callback(next, err)));
}
// Remove unwanted fields
delete req.file.fieldName;
delete req.file.originalName;
delete req.file.clientReportedMimeType;
delete req.file.clientReportedFileExtension;
delete req.file.detectedMimeType;
delete req.file.detectedFileExtension;
delete req.file.uuid;
delete req.file.field;
delete req.file.file;
delete req.file.filename;
delete req.file.truncated;
delete req.file.done;
// Operations
saveFile(req)
.then(() => req.file.path = req.file.path.concat('.temp')) // skipcq: JS-0086
.then(() => Promise.all([Thumbnail(req.file), Vibrant(req.file), Hash(req.file)]))
Promise.all([Thumbnail(req.file), Vibrant(req.file), Hash(req.file), fs.stat(req.file.path)])
// skipcq: JS-0086
.then(([thumbnail, vibrant, sha1]) => (
.then(([thumbnail, vibrant, sha1, stat]) => (
req.file.thumbnail = thumbnail, // skipcq: JS-0090
req.file.vibrant = vibrant, // skipcq: JS-0090
req.file.sha1 = sha1 // skipcq: JS-0090
req.file.sha1 = sha1, // skipcq: JS-0090
req.file.size = stat.size // skipcq: JS-0090
))
// Check if file size is too big
.then(() => { if (req.file.size / Math.pow(1024, 2) > maxUploadSize) throw new Error('LIMIT_FILE_SIZE'); })
// Save file
.then(() => log.debug('Saving file', req.file.originalname, s3enabled ? 'in S3' : 'on disk'))
.then(() =>
// skipcq: JS-0229
@ -109,12 +103,12 @@ function processUploaded(req, res, next) {
.catch(reject)
))
.then(() => log.debug('File saved', req.file.originalname, s3enabled ? 'in S3' : 'on disk'))
.then(() => fs.remove(req.file.path))
.then(() => log.debug('Temp file', 'deleted'))
.then(() => !s3enabled && (req.file.path = getLocalFilename(req))) // skipcq: JS-0090
.then(() => delete req.file.stream)
.then(() => next())
.catch(next);
.catch(next)
.finally(() => fs.remove(req.file.path))
.then(() => log.debug('Temp file', 'deleted'))
.catch((err) => log.err(err));
}
function deleteS3(file) {
@ -137,7 +131,6 @@ function bucketSize() {
}
module.exports = {
doUpload: multer({ limits: { fileSize: `${maxUploadSize}MB` } }).single('file'),
processUploaded,
deleteS3,
bucketSize

Loading…
Cancel
Save