diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6a68a0a --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules/ +uploads/* +!uploads/.gitkeep +.DS_Store +*.log diff --git a/README.md b/README.md index da29a78..8c23131 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,35 @@ -hi -this was supposed to be like a website but :( +# katdrop + +a minimal, smooth file transfer service. + +## features + +- minimal dark interface with smooth interactive particle background +- drag & drop files anywhere to upload instantly +- 10-minute auto-deletion timer per file with live countdown +- sleek upload progress bar +- safe path verification and collision-free file naming +- zero external CDN dependencies (works completely offline) + +## usage + +```bash +# install dependencies +npm install + +# start server +npm start +``` + +Runs by default on `http://localhost:3000` (or falls back to an available port if 3000 is in use). + +## endpoints + +- `POST /upload` - upload files (`file`) +- `GET /files` - list files +- `GET /uploads/:filename` - download file +- `DELETE /delete/:filename` - delete file + +## license + +MIT diff --git a/index.html b/index.html deleted file mode 100644 index ede1951..0000000 --- a/index.html +++ /dev/null @@ -1,106 +0,0 @@ - - - - - File Share - - - - -
-
-

File Share

-
- - -
-

Available Files

- -
- - - - diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..fe3afb3 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1014 @@ +{ + "name": "file-server", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "file-server", + "version": "1.0.0", + "dependencies": { + "express": "^4.18.2", + "multer": "1.4.5-lts.1" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "license": "MIT", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==", + "license": "MIT" + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", + "license": "MIT" + }, + "node_modules/body-parser": { + "version": "1.20.8", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.8.tgz", + "integrity": "sha512-JNcyFQ64OiijEkPzUBTCe+hyPXUD/3LEldGQ6iF5LR1w00mx9o7xtDWHXBY2iItjdCFGoilOLNQbH943ut7pHA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "~1.2.0", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "on-finished": "~2.4.1", + "qs": "~6.16.0", + "raw-body": "~2.5.3", + "type-is": "~1.6.18", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/body-parser/node_modules/qs": { + "version": "6.16.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz", + "integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==", + "license": "BSD-3-Clause", + "dependencies": { + "es-define-property": "^1.0.1", + "side-channel": "^1.1.1" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "license": "MIT" + }, + "node_modules/busboy": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", + "dependencies": { + "streamsearch": "^1.1.0" + }, + "engines": { + "node": ">=10.16.0" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "engines": [ + "node >= 0.8" + ], + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz", + "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==", + "license": "MIT" + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.22.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz", + "integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==", + "license": "MIT", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "~1.20.3", + "content-disposition": "~0.5.4", + "content-type": "~1.0.4", + "cookie": "~0.7.1", + "cookie-signature": "~1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.3.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "~0.1.12", + "proxy-addr": "~2.0.7", + "qs": "~6.14.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "~0.19.0", + "serve-static": "~1.16.2", + "setprototypeof": "1.2.0", + "statuses": "~2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/finalhandler": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz", + "integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "statuses": "~2.0.2", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "license": "MIT" + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "license": "MIT", + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/multer": { + "version": "1.4.5-lts.1", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz", + "integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==", + "deprecated": "Multer 1.x is impacted by a number of vulnerabilities, which have been patched in 2.x. You should upgrade to the latest 2.x version.", + "license": "MIT", + "dependencies": { + "append-field": "^1.0.0", + "busboy": "^1.0.0", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.4", + "object-assign": "^4.1.1", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz", + "integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==", + "license": "MIT" + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "license": "MIT" + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.14.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz", + "integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz", + "integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/readable-stream/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/send": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz", + "integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.1", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "~2.4.1", + "range-parser": "~1.2.1", + "statuses": "~2.0.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/serve-static": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz", + "integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==", + "license": "MIT", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "~0.19.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/streamsearch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/string_decoder/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "license": "MIT", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", + "license": "MIT" + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "license": "MIT", + "engines": { + "node": ">=0.4" + } + } + } +} diff --git a/package.json b/package.json index 8eaeed4..cc7a28d 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,22 @@ { - "name": "file-server", - "version": "1.0.0", + "name": "katdrop", + "version": "2.0.0", + "description": "Fast, sleek, local & web file transfer service", "main": "server.js", "scripts": { "start": "node server.js" }, + "keywords": [ + "file-transfer", + "file-drop", + "lan-share", + "express", + "katdrop" + ], + "author": "oiupoyt", + "license": "MIT", "dependencies": { - "express": "^4.18.2", - "multer": "1.4.5-lts.1" + "express": "^4.21.2", + "multer": "^1.4.5-lts.1" } } diff --git a/public/css/style.css b/public/css/style.css new file mode 100644 index 0000000..9dd6214 --- /dev/null +++ b/public/css/style.css @@ -0,0 +1,340 @@ +* { + box-sizing: border-box; + margin: 0; + padding: 0; + border-radius: 0 !important; /* Square everything out */ +} + +body { + font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; + background: #0b0b0b; + color: #e5e5e5; + min-height: 100vh; + position: relative; + overflow-x: hidden; + -webkit-font-smoothing: antialiased; +} + +#particles { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + pointer-events: none; + z-index: 0; +} + +.container { + position: relative; + z-index: 1; + max-width: 620px; + margin: 75px auto 60px; + padding: 0 20px; +} + +.header { + text-align: center; + margin-bottom: 30px; +} + +h1 { + font-size: 2.2rem; + font-weight: 600; + letter-spacing: -0.04em; + color: #fff; + margin-bottom: 4px; +} + +.subtitle { + font-size: 0.8rem; + color: #555; + letter-spacing: 0.05em; + text-transform: lowercase; +} + +/* Upload Drop Zone */ +.drop-zone { + border: 1px dashed #2a2a2a; + padding: 26px 20px; + background: rgba(15, 15, 15, 0.7); + backdrop-filter: blur(6px); + text-align: center; + transition: border-color 0.2s ease, background-color 0.2s ease; +} + +.drop-zone.dragover { + border-color: #555; + background: rgba(24, 24, 24, 0.85); +} + +.drop-actions { + display: flex; + justify-content: center; + align-items: center; + gap: 10px; +} + +.btn { + display: inline-flex; + align-items: center; + justify-content: center; + padding: 8px 18px; + background: #161616; + color: #ddd; + border: 1px solid #303030; + font-size: 0.8rem; + font-family: inherit; + cursor: pointer; + user-select: none; + text-decoration: none; + letter-spacing: 0.02em; + transition: all 0.15s ease; +} + +.btn:hover:not(:disabled) { + background: #242424; + border-color: #555; + color: #fff; +} + +.btn:active:not(:disabled) { + background: #fff; + color: #000; + border-color: #fff; +} + +.btn:disabled { + opacity: 0.3; + cursor: not-allowed; +} + +.btn-upload { + background: #1f1f1f; + border-color: #383838; +} + +.file-selection { + display: none; + margin-top: 14px; + font-size: 0.74rem; + color: #777; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + animation: fadeIn 0.15s ease; +} + +.file-selection.active { + display: block; +} + +/* Minimal Square Progress Bar */ +.progress-wrap { + display: none; + width: 100%; + height: 2px; + background: #1c1c1c; + margin-top: 12px; + overflow: hidden; +} + +.progress-wrap.active { + display: block; + animation: fadeIn 0.15s ease; +} + +@keyframes fadeIn { + from { opacity: 0; transform: translateY(-3px); } + to { opacity: 1; transform: translateY(0); } +} + +/* Files Section */ +.files-section { + margin-top: 42px; +} + +.files-header { + display: flex; + align-items: baseline; + justify-content: space-between; + border-bottom: 1px solid #1c1c1c; + padding-bottom: 10px; + margin-bottom: 12px; +} + +h2 { + font-size: 0.76rem; + font-weight: 500; + text-transform: uppercase; + letter-spacing: 0.12em; + color: #666; +} + +.file-count { + font-size: 0.72rem; + color: #444; +} + +ul { + list-style: none; + padding: 0; +} + +/* File Card Items */ +li.file-card { + display: flex; + align-items: center; + justify-content: space-between; + gap: 14px; + padding: 12px 14px; + margin-bottom: 6px; + background: rgba(17, 17, 17, 0.75); + border: 1px solid #202020; + transition: border-color 0.15s ease, background-color 0.15s ease, opacity 0.2s ease; +} + +li.file-card:hover { + background: rgba(24, 24, 24, 0.9); + border-color: #333; +} + +li.file-card.deleting { + opacity: 0; + transform: translateY(-4px); + pointer-events: none; +} + +.file-info { + display: flex; + align-items: baseline; + gap: 12px; + min-width: 0; + flex: 1; +} + +.file-name { + color: #e2e2e2; + font-size: 0.84rem; + font-weight: 500; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 360px; +} + +.file-meta { + display: flex; + align-items: baseline; + gap: 10px; + flex-shrink: 0; +} + +.file-size { + font-size: 0.7rem; + color: #555; + white-space: nowrap; +} + +.file-timer { + font-size: 0.7rem; + color: #666; + white-space: nowrap; + letter-spacing: 0.04em; + font-variant-numeric: tabular-nums; +} + +.file-timer.warning { + color: #f59e0b; +} + +.file-timer.critical { + color: #ff5555; +} + +.file-actions { + display: flex; + align-items: center; + gap: 6px; + flex-shrink: 0; +} + +.action-btn { + padding: 4px 10px; + font-size: 0.72rem; + font-family: inherit; + text-decoration: none; + background: #141414; + border: 1px solid #262626; + cursor: pointer; + letter-spacing: 0.02em; + transition: all 0.15s ease; +} + +.action-download { + color: #4db8ff; +} + +.action-download:hover { + background: #4db8ff; + color: #000; + border-color: #4db8ff; +} + +.action-delete { + color: #666; +} + +.action-delete:hover { + background: #ff5555; + color: #000; + border-color: #ff5555; +} + +.empty-state { + text-align: center; + color: #3a3a3a; + font-size: 0.78rem; + padding: 30px 0; + border: 1px dashed #1a1a1a; + margin-top: 4px; +} + +/* Toast */ +.toast { + position: fixed; + bottom: 24px; + left: 50%; + transform: translateX(-50%) translateY(10px); + background: #141414; + border: 1px solid #2f2f2f; + color: #ccc; + font-size: 0.75rem; + padding: 6px 14px; + opacity: 0; + pointer-events: none; + transition: all 0.15s ease; + z-index: 10; + letter-spacing: 0.02em; +} + +.toast.show { + opacity: 1; + transform: translateX(-50%) translateY(0); +} + +@media (max-width: 520px) { + .container { + margin-top: 40px; + padding: 0 14px; + } + + .file-name { + max-width: 170px; + } + + .file-info { + flex-direction: column; + gap: 2px; + } +} diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..6294a78 --- /dev/null +++ b/public/index.html @@ -0,0 +1,46 @@ + + + + + + katdrop + + + + + + + + +
+
+

katdrop

+

// minimal file transfer

+
+ +
+ +
+ + +
+
+
+
+
+
+ +
+
+

available files

+ 0 files +
+ +
+
+ +
+ + + + diff --git a/public/js/app.js b/public/js/app.js new file mode 100644 index 0000000..e44d35c --- /dev/null +++ b/public/js/app.js @@ -0,0 +1,386 @@ +/** + * katdrop - minimal, smooth, and interactive + */ +(function () { + 'use strict'; + + // DOM Elements + const dropZone = document.getElementById('dropZone'); + const fileInput = document.getElementById('fileInput'); + const uploadBtn = document.getElementById('uploadBtn'); + const fileSelection = document.getElementById('fileSelection'); + const progressWrap = document.getElementById('progressWrap'); + const progressBar = document.getElementById('progressBar'); + const fileList = document.getElementById('fileList'); + const fileCount = document.getElementById('fileCount'); + const toastEl = document.getElementById('toast'); + + let selectedFiles = []; + + // Toast + let toastTimeout; + function showToast(msg) { + clearTimeout(toastTimeout); + toastEl.textContent = `// ${msg}`; + toastEl.classList.add('show'); + toastTimeout = setTimeout(() => { + toastEl.classList.remove('show'); + }, 2200); + } + + // Interactive Particle Background + function initInteractiveParticles() { + const canvas = document.getElementById('particles'); + if (!canvas) return; + const ctx = canvas.getContext('2d'); + + let width = (canvas.width = window.innerWidth); + let height = (canvas.height = window.innerHeight); + + window.addEventListener('resize', () => { + width = canvas.width = window.innerWidth; + height = canvas.height = window.innerHeight; + }); + + // Mouse tracking for interactivity + const mouse = { + x: null, + y: null, + radius: 140 + }; + + window.addEventListener('mousemove', e => { + mouse.x = e.clientX; + mouse.y = e.clientY; + }); + + window.addEventListener('mouseleave', () => { + mouse.x = null; + mouse.y = null; + }); + + // Click to push particles slightly + window.addEventListener('click', e => { + for (const p of particles) { + const dx = p.x - e.clientX; + const dy = p.y - e.clientY; + const dist = Math.sqrt(dx * dx + dy * dy); + if (dist < 180 && dist > 0) { + const force = (180 - dist) / 180; + p.vx += (dx / dist) * force * 3; + p.vy += (dy / dist) * force * 3; + } + } + }); + + const particles = []; + const count = Math.min(50, Math.floor(width / 26)); + + for (let i = 0; i < count; i++) { + particles.push({ + x: Math.random() * width, + y: Math.random() * height, + vx: (Math.random() - 0.5) * 0.45, + vy: (Math.random() - 0.5) * 0.45, + radius: Math.random() * 1.5 + 1 + }); + } + + function animate() { + ctx.clearRect(0, 0, width, height); + + // Connect particles to each other + for (let i = 0; i < particles.length; i++) { + for (let j = i + 1; j < particles.length; j++) { + const dx = particles[i].x - particles[j].x; + const dy = particles[i].y - particles[j].y; + const dist = Math.sqrt(dx * dx + dy * dy); + if (dist < 115) { + ctx.strokeStyle = `rgba(255, 255, 255, ${0.06 * (1 - dist / 115)})`; + ctx.lineWidth = 0.8; + ctx.beginPath(); + ctx.moveTo(particles[i].x, particles[i].y); + ctx.lineTo(particles[j].x, particles[j].y); + ctx.stroke(); + } + } + } + + // Update & draw particles + connect to mouse + for (const p of particles) { + p.x += p.vx; + p.y += p.vy; + + // Dampen velocity back to normal + p.vx *= 0.985; + p.vy *= 0.985; + + // Boundary bounce + if (p.x < 0) { p.x = 0; p.vx *= -1; } + if (p.x > width) { p.x = width; p.vx *= -1; } + if (p.y < 0) { p.y = 0; p.vy *= -1; } + if (p.y > height) { p.y = height; p.vy *= -1; } + + // Interaction with mouse cursor + if (mouse.x !== null && mouse.y !== null) { + const mdx = mouse.x - p.x; + const mdy = mouse.y - p.y; + const mDist = Math.sqrt(mdx * mdx + mdy * mdy); + + if (mDist < mouse.radius) { + // Connect line to mouse + ctx.strokeStyle = `rgba(77, 184, 255, ${0.18 * (1 - mDist / mouse.radius)})`; + ctx.lineWidth = 0.9; + ctx.beginPath(); + ctx.moveTo(p.x, p.y); + ctx.lineTo(mouse.x, mouse.y); + ctx.stroke(); + + // Repel gently if very close + if (mDist < 70 && mDist > 0) { + const repel = (70 - mDist) / 70; + p.x -= (mdx / mDist) * repel * 1.5; + p.y -= (mdy / mDist) * repel * 1.5; + } + } + } + + // Draw particle dot + ctx.fillStyle = 'rgba(255, 255, 255, 0.28)'; + ctx.beginPath(); + ctx.arc(p.x, p.y, p.radius, 0, Math.PI * 2); + ctx.fill(); + } + + requestAnimationFrame(animate); + } + + animate(); + } + + // Safe HTML helper + function escapeHtml(str) { + return String(str) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + } + + // Countdown Timer Management + let countdownTimer = null; + + function formatTimeLeft(seconds) { + if (seconds <= 0) return '00:00'; + const m = Math.floor(seconds / 60); + const s = seconds % 60; + return `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`; + } + + function tickCountdowns() { + const timerEls = document.querySelectorAll('.file-timer'); + if (timerEls.length === 0) return; + + const now = Date.now(); + let hasExpired = false; + + timerEls.forEach(el => { + const expires = parseInt(el.dataset.expiresMs, 10); + if (isNaN(expires)) return; + + const remainingSec = Math.max(0, Math.ceil((expires - now) / 1000)); + el.textContent = formatTimeLeft(remainingSec); + + if (remainingSec <= 30) { + el.className = 'file-timer critical'; + } else if (remainingSec <= 120) { + el.className = 'file-timer warning'; + } else { + el.className = 'file-timer'; + } + + if (remainingSec === 0) { + hasExpired = true; + const card = el.closest('li.file-card'); + if (card) card.classList.add('deleting'); + } + }); + + if (hasExpired) { + setTimeout(fetchFiles, 400); + } + } + + function startCountdownLoop() { + if (countdownTimer) clearInterval(countdownTimer); + tickCountdowns(); + countdownTimer = setInterval(tickCountdowns, 1000); + } + + // Fetch and display files + async function fetchFiles() { + try { + const res = await fetch('/files'); + const files = await res.json(); + fileList.innerHTML = ''; + + if (!files || files.length === 0) { + fileList.innerHTML = '
  • // no files uploaded yet
  • '; + if (fileCount) fileCount.textContent = '0 files'; + return; + } + + if (fileCount) { + fileCount.textContent = `${files.length} file${files.length === 1 ? '' : 's'}`; + } + + files.forEach(file => { + const li = document.createElement('li'); + li.className = 'file-card'; + const name = typeof file === 'string' ? file : file.name; + const size = typeof file === 'object' && file.sizeFormatted ? file.sizeFormatted : ''; + const expiresMs = file.expiresAt ? new Date(file.expiresAt).getTime() : (Date.now() + 600000); + const remainingSec = Math.max(0, Math.ceil((expiresMs - Date.now()) / 1000)); + + li.innerHTML = ` +
    + ${escapeHtml(name)} +
    + ${size ? `${escapeHtml(size)}` : ''} + ${formatTimeLeft(remainingSec)} +
    +
    +
    + download + +
    + `; + fileList.appendChild(li); + }); + + startCountdownLoop(); + } catch (err) { + console.error(err); + fileList.innerHTML = '
  • // error reading files
  • '; + } + } + + // Delete file with smooth animation + window.deleteFile = async function (filename, cardElement) { + if (cardElement) cardElement.classList.add('deleting'); + + try { + const res = await fetch(`/delete/${encodeURIComponent(filename)}`, { method: 'DELETE' }); + if (res.ok) { + showToast('file deleted'); + setTimeout(() => { + fetchFiles(); + }, 180); + } else { + if (cardElement) cardElement.classList.remove('deleting'); + showToast('failed to delete'); + } + } catch (err) { + if (cardElement) cardElement.classList.remove('deleting'); + showToast('delete error'); + } + }; + + // Update selected files + function updateFileSelection(files) { + selectedFiles = Array.from(files); + if (selectedFiles.length === 0) { + fileSelection.textContent = ''; + fileSelection.classList.remove('active'); + uploadBtn.disabled = true; + } else if (selectedFiles.length === 1) { + fileSelection.textContent = `> ${selectedFiles[0].name}`; + fileSelection.classList.add('active'); + uploadBtn.disabled = false; + } else { + fileSelection.textContent = `> ${selectedFiles.length} files selected`; + fileSelection.classList.add('active'); + uploadBtn.disabled = false; + } + } + + // Upload files with smooth progress bar + function uploadSelectedFiles() { + if (selectedFiles.length === 0) return; + + const formData = new FormData(); + selectedFiles.forEach(f => formData.append('file', f)); + + progressWrap.classList.add('active'); + progressBar.style.width = '0%'; + uploadBtn.disabled = true; + + const xhr = new XMLHttpRequest(); + + xhr.upload.addEventListener('progress', e => { + if (e.lengthComputable) { + const pct = Math.round((e.loaded / e.total) * 100); + progressBar.style.width = `${pct}%`; + } + }); + + xhr.onload = () => { + progressBar.style.width = '100%'; + setTimeout(() => { + progressWrap.classList.remove('active'); + progressBar.style.width = '0%'; + fileInput.value = ''; + updateFileSelection([]); + fetchFiles(); + showToast('upload complete'); + }, 250); + }; + + xhr.onerror = () => { + progressWrap.classList.remove('active'); + uploadBtn.disabled = false; + showToast('upload failed'); + }; + + xhr.open('POST', '/upload'); + xhr.send(formData); + } + + // Listeners + fileInput.addEventListener('change', e => { + updateFileSelection(e.target.files); + }); + + uploadBtn.addEventListener('click', () => { + uploadSelectedFiles(); + }); + + // Drag and drop + ['dragenter', 'dragover'].forEach(name => { + dropZone.addEventListener(name, e => { + e.preventDefault(); + dropZone.classList.add('dragover'); + }); + window.addEventListener(name, e => e.preventDefault()); + }); + + ['dragleave', 'drop'].forEach(name => { + dropZone.addEventListener(name, e => { + e.preventDefault(); + dropZone.classList.remove('dragover'); + }); + window.addEventListener(name, e => e.preventDefault()); + }); + + dropZone.addEventListener('drop', e => { + if (e.dataTransfer && e.dataTransfer.files && e.dataTransfer.files.length > 0) { + updateFileSelection(e.dataTransfer.files); + uploadSelectedFiles(); + } + }); + + // Init + initInteractiveParticles(); + fetchFiles(); +})(); diff --git a/server.js b/server.js index 13ae835..1f9429b 100644 --- a/server.js +++ b/server.js @@ -1,46 +1,211 @@ const express = require('express'); -const multer = require('multer'); +const multer = require('multer'); const fs = require('fs'); const path = require('path'); const app = express(); -const PORT = process.env.PORT || 3000; +let currentPort = parseInt(process.env.PORT, 10) || 3000; +// Directories const uploadDir = path.join(__dirname, 'uploads'); -if (!fs.existsSync(uploadDir)) fs.mkdirSync(uploadDir); +const publicDir = path.join(__dirname, 'public'); -// File storage setup +if (!fs.existsSync(uploadDir)) { + fs.mkdirSync(uploadDir, { recursive: true }); +} + +// 10-Minute File Expiration (in milliseconds) +const FILE_TTL_MS = 10 * 60 * 1000; + +// Utility: format file size +function formatBytes(bytes) { + if (!bytes || bytes === 0) return '0 B'; + const k = 1024; + const sizes = ['B', 'KB', 'MB', 'GB']; + const i = Math.floor(Math.log(bytes) / Math.log(k)); + return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i]; +} + +// Utility: Safe unique filename (prevent overwrites and directory traversal) +function getSafeUniqueName(destination, originalName) { + const base = path.basename(originalName).replace(/[^\w\s.-]/gi, '_').trim() || 'file'; + const ext = path.extname(base); + const nameOnly = path.basename(base, ext) || 'file'; + + let candidate = `${nameOnly}${ext}`; + let counter = 1; + while (fs.existsSync(path.join(destination, candidate))) { + candidate = `${nameOnly} (${counter})${ext}`; + counter++; + } + return candidate; +} + +// Utility: Validate path and prevent directory traversal +function getSafeFilePath(filename) { + if (!filename || typeof filename !== 'string') return null; + const safeName = path.basename(filename); + const resolvedPath = path.resolve(uploadDir, safeName); + if (!resolvedPath.startsWith(uploadDir + path.sep) && resolvedPath !== uploadDir) { + return null; + } + return { resolvedPath, safeName }; +} + +// Automatic cleanup of expired files (older than 10 minutes) +async function cleanupExpiredFiles() { + try { + const entries = await fs.promises.readdir(uploadDir); + const now = Date.now(); + + for (const name of entries) { + if (name.startsWith('.')) continue; // Preserve .gitkeep and hidden files + const fullPath = path.join(uploadDir, name); + try { + const stats = await fs.promises.stat(fullPath); + if (stats.isFile() && (now - stats.mtimeMs) >= FILE_TTL_MS) { + await fs.promises.unlink(fullPath); + } + } catch (err) { + // Ignore files already deleted or locked + } + } + } catch (err) { + // Ignore read errors during sweep + } +} + +// Run cleanup sweep every 10 seconds (unref'd to prevent blocking process exit) +const cleanupInterval = setInterval(cleanupExpiredFiles, 10 * 1000); +cleanupInterval.unref(); + +// Multer storage const storage = multer.diskStorage({ destination: (req, file, cb) => cb(null, uploadDir), - filename: (req, file, cb) => cb(null, file.originalname) + filename: (req, file, cb) => { + cb(null, getSafeUniqueName(uploadDir, file.originalname)); + } }); -const upload = multer({ storage }); - -// Middleware -app.use(express.static(__dirname)); // serve index.html -app.use('/uploads', express.static(uploadDir)); - -// Upload endpoint -app.post('/upload', upload.single('file'), (req, res) => { - res.send('File uploaded!'); +const upload = multer({ + storage, + limits: { fileSize: 2 * 1024 * 1024 * 1024 } // 2GB }); -// List files -app.get('/files', (req, res) => { - fs.readdir(uploadDir, (err, files) => { - if (err) return res.status(500).send('Error reading files'); +// Middlewares +app.use(express.json()); +app.use(express.static(publicDir)); + +// Upload endpoint (supports single or multiple files) +app.post('/upload', upload.array('file', 20), (req, res) => { + if (!req.files || req.files.length === 0) { + return res.status(400).json({ error: 'No files uploaded' }); + } + + const now = Date.now(); + const uploaded = req.files.map(f => ({ + name: f.filename, + size: f.size, + sizeFormatted: formatBytes(f.size), + expiresAt: new Date(now + FILE_TTL_MS).toISOString(), + remainingSeconds: Math.floor(FILE_TTL_MS / 1000) + })); + res.json({ success: true, files: uploaded }); +}); + +// List files with metadata, remaining TTL, and on-demand expiration check +app.get('/files', async (req, res) => { + try { + const entries = await fs.promises.readdir(uploadDir); + const files = []; + const now = Date.now(); + + for (const name of entries) { + if (name.startsWith('.')) continue; + const fullPath = path.join(uploadDir, name); + try { + const stats = await fs.promises.stat(fullPath); + if (!stats.isFile()) continue; + + const ageMs = now - stats.mtimeMs; + // Immediate purge if expired + if (ageMs >= FILE_TTL_MS) { + fs.promises.unlink(fullPath).catch(() => {}); + continue; + } + + const remainingMs = Math.max(0, FILE_TTL_MS - ageMs); + const remainingSeconds = Math.ceil(remainingMs / 1000); + + files.push({ + name, + size: stats.size, + sizeFormatted: formatBytes(stats.size), + modifiedAt: stats.mtime, + expiresAt: new Date(stats.mtimeMs + FILE_TTL_MS).toISOString(), + remainingSeconds + }); + } catch (e) { + continue; + } + } + + // Sort newest first + files.sort((a, b) => new Date(b.modifiedAt) - new Date(a.modifiedAt)); res.json(files); - }); + } catch (err) { + res.status(500).json({ error: 'Error reading files' }); + } +}); + +// Download / direct link with on-demand expiration check +app.get('/uploads/:filename', (req, res) => { + const safe = getSafeFilePath(req.params.filename); + if (!safe || !fs.existsSync(safe.resolvedPath)) { + return res.status(404).send('File not found'); + } + + try { + const stats = fs.statSync(safe.resolvedPath); + if ((Date.now() - stats.mtimeMs) >= FILE_TTL_MS) { + fs.unlink(safe.resolvedPath, () => {}); + return res.status(410).send('File expired'); + } + } catch (err) { + return res.status(404).send('File not found'); + } + + res.download(safe.resolvedPath, safe.safeName); }); // Delete file -app.delete('/delete/:filename', (req, res) => { - const filePath = path.join(uploadDir, req.params.filename); - fs.unlink(filePath, err => { - if (err) return res.status(500).send('Error deleting file'); +app.delete('/delete/:filename', async (req, res) => { + const safe = getSafeFilePath(req.params.filename); + if (!safe) return res.status(400).send('Invalid filename'); + + try { + await fs.promises.unlink(safe.resolvedPath); res.send('File deleted'); - }); + } catch (err) { + res.status(500).send('Error deleting file'); + } }); -// Start server -app.listen(PORT, () => console.log(`Server running on port ${PORT}`)); +// Start Server with fallback port handling +function startServer(port, maxAttempts = 10) { + const server = app.listen(port, '0.0.0.0', () => { + currentPort = port; + console.log(`\nkatdrop running on http://localhost:${port}\n`); + cleanupExpiredFiles(); // Run initial cleanup on startup + }); + + server.on('error', (err) => { + if (err.code === 'EADDRINUSE' && !process.env.PORT && maxAttempts > 0) { + startServer(port + 1, maxAttempts - 1); + } else { + console.error(`Failed to start server on port ${port}:`, err.message); + process.exit(1); + } + }); +} + +startServer(currentPort); diff --git a/uploads/.gitkeep b/uploads/.gitkeep new file mode 100644 index 0000000..2b63067 --- /dev/null +++ b/uploads/.gitkeep @@ -0,0 +1 @@ +# KatDrop uploads directory