From 784bfb5392a11adb38947d749f720bb4b96f40fc Mon Sep 17 00:00:00 2001 From: Ronja Date: Sat, 5 Sep 2026 21:09:42 +0200 Subject: [PATCH 1/8] feat(rest-API): implement route /api/cat and .env.example and start script and cat react component to check that it works. --- t29-project-1/.env.example | 3 + t29-project-1/package-lock.json | 890 ++++++++++++++++++++++++++- t29-project-1/package.json | 6 +- t29-project-1/server/index.js | 37 ++ t29-project-1/src/App.css | 24 + t29-project-1/src/App.tsx | 3 + t29-project-1/src/components/Cat.tsx | 45 ++ t29-project-1/vite.config.ts | 9 + 8 files changed, 1014 insertions(+), 3 deletions(-) create mode 100644 t29-project-1/.env.example create mode 100644 t29-project-1/server/index.js create mode 100644 t29-project-1/src/components/Cat.tsx diff --git a/t29-project-1/.env.example b/t29-project-1/.env.example new file mode 100644 index 0000000..2523621 --- /dev/null +++ b/t29-project-1/.env.example @@ -0,0 +1,3 @@ +# Copy to .env and set your key +CAT_API_KEY=your_cat_api_key_here +PORT=3001 diff --git a/t29-project-1/package-lock.json b/t29-project-1/package-lock.json index 5a10040..29971bf 100644 --- a/t29-project-1/package-lock.json +++ b/t29-project-1/package-lock.json @@ -8,6 +8,9 @@ "name": "t29-project-1", "version": "0.0.0", "dependencies": { + "cors": "^2.8.6", + "dotenv": "^17.4.2", + "express": "^5.2.1", "react": "^19.2.8", "react-dom": "^19.2.8" }, @@ -1175,6 +1178,19 @@ } } }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/acorn": { "version": "8.18.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz", @@ -1238,6 +1254,43 @@ "node": ">=6.0.0" } }, + "node_modules/body-parser": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz", + "integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^2.0.0", + "debug": "^4.4.3", + "http-errors": "^2.0.1", + "iconv-lite": "^0.7.2", + "on-finished": "^2.4.1", + "qs": "^6.15.2", + "raw-body": "^3.0.2", + "type-is": "^2.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/body-parser/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/brace-expansion": { "version": "5.0.9", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz", @@ -1285,6 +1338,15 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "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/cacheable": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/cacheable/-/cacheable-2.5.0.tgz", @@ -1299,6 +1361,35 @@ "qified": "^0.10.1" } }, + "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/caniuse-lite": { "version": "1.0.30001810", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz", @@ -1320,6 +1411,28 @@ ], "license": "CC-BY-4.0" }, + "node_modules/content-disposition": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz", + "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "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/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", @@ -1327,6 +1440,41 @@ "dev": true, "license": "MIT" }, + "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.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/cors": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz", + "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -1353,7 +1501,6 @@ "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "dev": true, "license": "MIT", "dependencies": { "ms": "^2.1.3" @@ -1374,6 +1521,15 @@ "dev": true, "license": "MIT" }, + "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/detect-libc": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", @@ -1384,6 +1540,38 @@ "node": ">=8" } }, + "node_modules/dotenv": { + "version": "17.4.2", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.2.tgz", + "integrity": "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "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/electron-to-chromium": { "version": "1.5.422", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.422.tgz", @@ -1391,6 +1579,45 @@ "dev": true, "license": "ISC" }, + "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/escalade": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", @@ -1401,6 +1628,12 @@ "node": ">=6" } }, + "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/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -1599,6 +1832,58 @@ "node": ">=0.10.0" } }, + "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": "5.2.1", + "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", + "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.1", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -1648,6 +1933,27 @@ "flat-cache": "^6.1.23" } }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -1684,6 +1990,24 @@ "dev": true, "license": "ISC" }, + "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": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -1699,6 +2023,15 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "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/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -1709,6 +2042,43 @@ "node": ">=6.9.0" } }, + "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/glob-parent": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", @@ -1735,6 +2105,30 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "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/hashery": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/hashery/-/hashery-1.5.1.tgz", @@ -1748,6 +2142,18 @@ "node": ">=20" } }, + "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/hermes-estree": { "version": "0.25.1", "resolved": "https://registry.npmjs.org/hermes-estree/-/hermes-estree-0.25.1.tgz", @@ -1772,6 +2178,26 @@ "dev": true, "license": "MIT" }, + "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/husky": { "version": "9.1.7", "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", @@ -1788,6 +2214,22 @@ "url": "https://github.com/sponsors/typicode" } }, + "node_modules/iconv-lite": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz", + "integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -1808,6 +2250,21 @@ "node": ">=0.8.19" } }, + "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/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -1831,6 +2288,12 @@ "node": ">=0.10.0" } }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -2232,6 +2695,65 @@ "yallist": "^3.0.2" } }, + "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": "1.1.1", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.1.tgz", + "integrity": "sha512-yz3xRaG20c6/BOzvYoDaGtPmGscs7YivItZEEqe6GbwNfHuxu9YNmvnEkMzKldAGY4/80pRcQRZSEnhquk9XuQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/minimatch": { "version": "10.2.6", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", @@ -2252,7 +2774,6 @@ "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, "license": "MIT" }, "node_modules/nanoid": { @@ -2281,6 +2802,35 @@ "dev": true, "license": "MIT" }, + "node_modules/negotiator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.1.0.tgz", + "integrity": "sha512-NMPBRMJgiQHjbd8phG3Vebdx4kZ1H121rbl5IkMqeOsahptB9BKo/d7oJ3zTXqTgagn2bWlNSXkh0QUGM31RYg==", + "license": "MIT", + "dependencies": { + "content-type": "^2.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/negotiator/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/node-releases": { "version": "2.0.54", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.54.tgz", @@ -2291,6 +2841,48 @@ "node": ">=18" } }, + "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/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, "node_modules/optionator": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", @@ -2341,6 +2933,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "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-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -2361,6 +2962,16 @@ "node": ">=8" } }, + "node_modules/path-to-regexp": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", + "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -2436,6 +3047,19 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "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/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -2466,6 +3090,50 @@ "dev": true, "license": "MIT" }, + "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/range-parser": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz", + "integrity": "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/react": { "version": "19.2.8", "resolved": "https://registry.npmjs.org/react/-/react-19.2.8.tgz", @@ -2521,6 +3189,28 @@ "@rolldown/binding-win32-x64-msvc": "1.2.7" } }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "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/scheduler": { "version": "0.27.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.27.0.tgz", @@ -2537,6 +3227,57 @@ "semver": "bin/semver.js" } }, + "node_modules/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/serve-static": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "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/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -2560,6 +3301,78 @@ "node": ">=8" } }, + "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/source-map-js": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", @@ -2570,6 +3383,15 @@ "node": ">=0.10.0" } }, + "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/string-argv": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.2.tgz", @@ -2607,6 +3429,15 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, + "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/ts-api-utils": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz", @@ -2633,6 +3464,37 @@ "node": ">= 0.8.0" } }, + "node_modules/type-is": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz", + "integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==", + "license": "MIT", + "dependencies": { + "content-type": "^2.0.0", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/type-is/node_modules/content-type": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-2.1.0.tgz", + "integrity": "sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/typescript": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", @@ -2678,6 +3540,15 @@ "dev": true, "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/update-browserslist-db": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.2.tgz", @@ -2719,6 +3590,15 @@ "punycode": "^2.1.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/vite": { "version": "8.2.2", "resolved": "https://registry.npmjs.org/vite/-/vite-8.2.2.tgz", @@ -2823,6 +3703,12 @@ "node": ">=0.10.0" } }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", diff --git a/t29-project-1/package.json b/t29-project-1/package.json index 878378c..9a60a95 100644 --- a/t29-project-1/package.json +++ b/t29-project-1/package.json @@ -10,7 +10,8 @@ "preview": "vite preview", "format": "prettier --write \"src/**/*.{js,ts,tsx,jsx,json,css,md}\"", "prettier:check": "prettier --check \"src/**/*.{js,ts,tsx,jsx,json,css,md}\"", - "prepare": "husky install" + "prepare": "husky install", + "start:server": "node server/index.js" }, "lint-staged": { "src/**/*.{js,ts,tsx,jsx}": [ @@ -22,6 +23,9 @@ ] }, "dependencies": { + "cors": "^2.8.6", + "dotenv": "^17.4.2", + "express": "^5.2.1", "react": "^19.2.8", "react-dom": "^19.2.8" }, diff --git a/t29-project-1/server/index.js b/t29-project-1/server/index.js new file mode 100644 index 0000000..b629dcb --- /dev/null +++ b/t29-project-1/server/index.js @@ -0,0 +1,37 @@ +import dotenv from 'dotenv'; +import express from 'express'; +import cors from 'cors'; + +dotenv.config(); + +// Create an Express application +const app = express(); +// Enable CORS for all routes +//cors is a middleware that allows cross-origin requests from the frontend to the backend +app.use(cors()); + +const CAT_API_URL = 'https://api.thecatapi.com/v1/images/search?limit=1'; +const API_KEY = process.env.CAT_API_KEY; + +// Define a route to fetch a random cat image from the Cat API +app.get('/api/cat', async (req, res) => { + try { + // If an API key is provided, include it in the request headers + const headers = API_KEY ? { 'x-api-key': API_KEY } : {}; + // Fetch a random cat image from the Cat API + const response = await fetch(CAT_API_URL, { headers }); + // If the response is not OK, return the error message and status code + if (!response.ok) { + const text = await response.text(); + return res.status(response.status).send(text); + } + const data = await response.json(); + res.json(data[0] || {}); + } catch (err) { + console.error(err); + res.status(500).json({ error: 'failed to fetch cat' }); + } +}); + +const port = process.env.PORT || 3001; +app.listen(port, () => console.log(`Cat API proxy running on http://localhost:${port}`)); diff --git a/t29-project-1/src/App.css b/t29-project-1/src/App.css index f90339d..0928804 100644 --- a/t29-project-1/src/App.css +++ b/t29-project-1/src/App.css @@ -182,3 +182,27 @@ border-right-color: var(--border); } } + +.cat-section { + display: flex; + flex-direction: column; + align-items: center; + gap: 12px; + padding: 20px 0; +} + +.cat-image-wrap { + display: flex; + justify-content: center; +} + +.cat-image { + max-width: 320px; + width: 100%; + border-radius: 8px; + box-shadow: var(--shadow); +} + +.cat-error { + color: red; +} diff --git a/t29-project-1/src/App.tsx b/t29-project-1/src/App.tsx index 9ca8e8d..a65fd8b 100644 --- a/t29-project-1/src/App.tsx +++ b/t29-project-1/src/App.tsx @@ -3,6 +3,7 @@ import heroImg from './assets/hero.png' import reactLogo from './assets/react.svg' import viteLogo from './assets/vite.svg' import './App.css' +import Cat from './components/Cat' function App() { const [count, setCount] = useState(0) @@ -32,6 +33,8 @@ function App() {
+ +
{error}
} + {cat?.url && ( +
+ Random cat +
+ )} +
+ ) +} diff --git a/t29-project-1/vite.config.ts b/t29-project-1/vite.config.ts index 9982072..32045c0 100644 --- a/t29-project-1/vite.config.ts +++ b/t29-project-1/vite.config.ts @@ -4,4 +4,13 @@ import { defineConfig } from 'vite' // https://vite.dev/config/ export default defineConfig({ plugins: [react()], + server: { + proxy: { + '/api': { + target: 'http://localhost:3001', + changeOrigin: true, + secure: false, + }, + }, + }, }) From 992b1dea0329b19fdefae39c9a61e5ce6fad725f Mon Sep 17 00:00:00 2001 From: Ronja Date: Sat, 5 Sep 2026 21:16:15 +0200 Subject: [PATCH 2/8] docs(api):document the cat api --- t29-project-1/docs/CAT_API.md | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 t29-project-1/docs/CAT_API.md diff --git a/t29-project-1/docs/CAT_API.md b/t29-project-1/docs/CAT_API.md new file mode 100644 index 0000000..8653b92 --- /dev/null +++ b/t29-project-1/docs/CAT_API.md @@ -0,0 +1,58 @@ +# Cat API Documentation + +## Purpose +This document describes the local backend proxy endpoint that fetches random cat images from The Cat API and how the frontend interacts with it. + +## Endpoint +- GET /api/cat + - Returns: JSON object containing a single image item from The Cat API, for example: + { + "id": "d0p", + "url": "https://.../d0p.png", + "width": 1024, + "height": 1024 + } + +## Server implementation +- File: `server/index.js` +- Uses: `express`, `cors`, `dotenv` +- Behavior: forwards a request to `https://api.thecatapi.com/v1/images/search?limit=1` and returns the first item in the JSON array. +- If `CAT_API_KEY` is present in environment, it is sent in the request header `x-api-key`. + +## Environment +- Create a `.env` file (copy from `.env.example`) and set: +``` +CAT_API_KEY=your_cat_api_key_here +PORT=3001 +``` +- The API key is optional for basic requests but recommended for higher rate limits. + +## Frontend usage +- The React component `src/components/Cat.tsx` fetches the endpoint. +- Development: Vite is configured to proxy `/api` to `http://localhost:3001` so you can run both frontend and backend locally. +- In production, configure `VITE_API_BASE` if the backend is deployed to a different origin. The component will use `VITE_API_BASE` if present: +``` +VITE_API_BASE=http://your-backend.example.com +``` + +## Examples +Curl (server running locally): +```bash +curl http://localhost:3001/api/cat +``` +Frontend (React `fetch`): +```js +const res = await fetch('/api/cat'); +const data = await res.json(); +console.log(data.url); +``` + +## How to run locally +1. Install dependencies: `npm install` +2. Start backend: `npm run start:server` (the server prints `Cat API proxy running on http://localhost:3001`) +3. Start frontend: `npm run dev` +4. Open the app and click "Fetch a cat" + +## Notes +- Keep the `CAT_API_KEY` secret (do not commit it). Use environment variables for deployments. +- The proxy helps avoid exposing the API key to the client and works around CORS/rate-limit issues. From 56b910c53814ae0c16101d6c5c4e4536a6205228 Mon Sep 17 00:00:00 2001 From: Ronja Date: Wed, 9 Sep 2026 11:21:55 +0200 Subject: [PATCH 3/8] feat(cat): add breed filtering --- t29-project-1/server/index.js | 35 +++++++++++++++++++++++++--- t29-project-1/src/components/Cat.tsx | 16 ++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/t29-project-1/server/index.js b/t29-project-1/server/index.js index b629dcb..2ec0127 100644 --- a/t29-project-1/server/index.js +++ b/t29-project-1/server/index.js @@ -10,16 +10,45 @@ const app = express(); //cors is a middleware that allows cross-origin requests from the frontend to the backend app.use(cors()); -const CAT_API_URL = 'https://api.thecatapi.com/v1/images/search?limit=1'; +const CAT_API_URL = 'https://api.thecatapi.com/v1/images/search'; +const CAT_BREEDS_URL = 'https://api.thecatapi.com/v1/breeds'; const API_KEY = process.env.CAT_API_KEY; +const BREED_IDS_PATTERN = /^[a-z0-9]+(?:,[a-z0-9]+)*$/i; + +const apiHeaders = API_KEY ? { 'x-api-key': API_KEY } : {}; + +app.get('/api/breeds', async (req, res) => { + try { + const breedsUrl = new URL(CAT_BREEDS_URL); + breedsUrl.searchParams.set('limit', '10'); + const response = await fetch(breedsUrl, { headers: apiHeaders }); + if (!response.ok) { + const text = await response.text(); + return res.status(response.status).send(text); + } + const data = await response.json(); + res.json(data); + } catch (err) { + console.error(err); + res.status(500).json({ error: 'failed to fetch breeds' }); + } +}); // Define a route to fetch a random cat image from the Cat API app.get('/api/cat', async (req, res) => { try { + const breedIds = typeof req.query.breed_ids === 'string' ? req.query.breed_ids.trim() : ''; + if (breedIds && !BREED_IDS_PATTERN.test(breedIds)) { + return res.status(400).json({ error: 'Invalid breed_ids filter' }); + } + + const searchUrl = new URL(CAT_API_URL); + searchUrl.searchParams.set('limit', '1'); + if (breedIds) searchUrl.searchParams.set('breed_ids', breedIds); + // If an API key is provided, include it in the request headers - const headers = API_KEY ? { 'x-api-key': API_KEY } : {}; // Fetch a random cat image from the Cat API - const response = await fetch(CAT_API_URL, { headers }); + const response = await fetch(searchUrl, { headers: apiHeaders }); // If the response is not OK, return the error message and status code if (!response.ok) { const text = await response.text(); diff --git a/t29-project-1/src/components/Cat.tsx b/t29-project-1/src/components/Cat.tsx index 7e564f7..932d7da 100644 --- a/t29-project-1/src/components/Cat.tsx +++ b/t29-project-1/src/components/Cat.tsx @@ -2,6 +2,7 @@ import { useState } from 'react' // Defines the type for the cat object returned by the API type CatData = { url?: string; id?: string; width?: number; height?: number } +type CatFilters = { breedId?: string } // Component that fetches and displays a random cat image from the API export default function Cat() { @@ -11,13 +12,17 @@ export default function Cat() { const [error, setError] = useState(null) // Function that fetches a random cat image from the API - async function fetchCat() { + async function fetchCat(filters: CatFilters = {}) { setLoading(true) setError(null) // Read API_BASE from environment variables, fallback to localhost if not defined try { const API_BASE = (import.meta.env.VITE_API_BASE as string) || 'http://localhost:3001' - const res = await fetch(`${API_BASE}/api/cat`) + const params = new URLSearchParams() + const selectedBreedId = filters.breedId?.trim() + if (selectedBreedId) params.set('breed_ids', selectedBreedId) + const query = params.toString() + const res = await fetch(`${API_BASE}/api/cat${query ? `?${query}` : ''}`) if (!res.ok) throw new Error(`Status ${res.status}`) const data = await res.json() setCat(data) @@ -31,7 +36,12 @@ export default function Cat() { // Return JSX: button to fetch a cat, show error if any, and display the cat image when available return (
- {error &&
{error}
} From a2ba6613f863516aaf1e17d3285bc12f2f7f59a9 Mon Sep 17 00:00:00 2001 From: Ronja Date: Wed, 9 Sep 2026 11:22:27 +0200 Subject: [PATCH 4/8] docs(cat): add API usage guide --- t29-project-1/docs/CAT_API.md | 58 ------------- t29-project-1/src/docs/CAT_API.md | 130 ++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 58 deletions(-) delete mode 100644 t29-project-1/docs/CAT_API.md create mode 100644 t29-project-1/src/docs/CAT_API.md diff --git a/t29-project-1/docs/CAT_API.md b/t29-project-1/docs/CAT_API.md deleted file mode 100644 index 8653b92..0000000 --- a/t29-project-1/docs/CAT_API.md +++ /dev/null @@ -1,58 +0,0 @@ -# Cat API Documentation - -## Purpose -This document describes the local backend proxy endpoint that fetches random cat images from The Cat API and how the frontend interacts with it. - -## Endpoint -- GET /api/cat - - Returns: JSON object containing a single image item from The Cat API, for example: - { - "id": "d0p", - "url": "https://.../d0p.png", - "width": 1024, - "height": 1024 - } - -## Server implementation -- File: `server/index.js` -- Uses: `express`, `cors`, `dotenv` -- Behavior: forwards a request to `https://api.thecatapi.com/v1/images/search?limit=1` and returns the first item in the JSON array. -- If `CAT_API_KEY` is present in environment, it is sent in the request header `x-api-key`. - -## Environment -- Create a `.env` file (copy from `.env.example`) and set: -``` -CAT_API_KEY=your_cat_api_key_here -PORT=3001 -``` -- The API key is optional for basic requests but recommended for higher rate limits. - -## Frontend usage -- The React component `src/components/Cat.tsx` fetches the endpoint. -- Development: Vite is configured to proxy `/api` to `http://localhost:3001` so you can run both frontend and backend locally. -- In production, configure `VITE_API_BASE` if the backend is deployed to a different origin. The component will use `VITE_API_BASE` if present: -``` -VITE_API_BASE=http://your-backend.example.com -``` - -## Examples -Curl (server running locally): -```bash -curl http://localhost:3001/api/cat -``` -Frontend (React `fetch`): -```js -const res = await fetch('/api/cat'); -const data = await res.json(); -console.log(data.url); -``` - -## How to run locally -1. Install dependencies: `npm install` -2. Start backend: `npm run start:server` (the server prints `Cat API proxy running on http://localhost:3001`) -3. Start frontend: `npm run dev` -4. Open the app and click "Fetch a cat" - -## Notes -- Keep the `CAT_API_KEY` secret (do not commit it). Use environment variables for deployments. -- The proxy helps avoid exposing the API key to the client and works around CORS/rate-limit issues. diff --git a/t29-project-1/src/docs/CAT_API.md b/t29-project-1/src/docs/CAT_API.md new file mode 100644 index 0000000..fca77ef --- /dev/null +++ b/t29-project-1/src/docs/CAT_API.md @@ -0,0 +1,130 @@ +# Cat API guide for UI developers + +This document explains how the frontend can request cat images through our local +backend proxy. + +## Start the API locally + +From the `t29-project-1` folder, run: + +```bash +npm run start:server +``` + +The backend runs on `http://localhost:3001`. + +The Vite development server also proxies `/api` requests to this backend. This +means a frontend request can use either `/api/...` or the full local URL. + +## Get a random cat + +### Request + +```js +const response = await fetch('/api/cat'); +const cat = await response.json(); +``` + +The endpoint returns one cat image object: + +```json +{ + "id": "d0p", + "url": "https://.../d0p.png", + "width": 1024, + "height": 1024 +} +``` + +Display the image with the returned `url`: + +```jsx +Random cat +``` + +## Get breeds + +The breed endpoint returns up to 10 breeds. Each breed contains an ID and a +human-readable name: + +```js +const response = await fetch('/api/breeds'); +const breeds = await response.json(); + +breeds.forEach((breed) => { + console.log(breed.id, breed.name); +}); +``` + +Example response: + +```json +[ + { + "id": "abys", + "name": "Abyssinian" + } +] +``` + +The ID is intended for API requests. The name is the value that should be shown +to users in a future filter control. + +## Get a filtered cat image + +Use the `breed_ids` query parameter with a breed ID from `/api/breeds`: + +```js +const breedId = 'beng'; +const params = new URLSearchParams({ breed_ids: breedId }); +const response = await fetch(`/api/cat?${params}`); +const cat = await response.json(); +``` + +This requests one random Bengal cat image. The backend always adds `limit=1` +and returns the first image from The Cat API response. + +Multiple breed IDs can be sent as a comma-separated value: + +```js +const params = new URLSearchParams({ breed_ids: 'beng,siam' }); +const response = await fetch(`/api/cat?${params}`); +``` + +## Handle errors + +Always check `response.ok` before using the response: + +```js +const response = await fetch('/api/cat?breed_ids=beng'); + +if (!response.ok) { + const message = await response.text(); + throw new Error(message || `Request failed with status ${response.status}`); +} + +const cat = await response.json(); +``` + +An invalid `breed_ids` value returns status `400`. Errors from The Cat API are +forwarded by the backend, and unexpected server errors return status `500`. + +## API base URL + +The existing `Cat` component uses `VITE_API_BASE` when it is set and otherwise +falls back to `http://localhost:3001`: + +```js +const API_BASE = import.meta.env.VITE_API_BASE || 'http://localhost:3001'; +const response = await fetch(`${API_BASE}/api/cat`); +``` + +For local development, start both servers: + +```bash +npm run start:server +npm run dev +``` + +Keep `CAT_API_KEY` in the backend environment only. It must never be exposed in +frontend code. From 96a287a30a81ccf45e1be9e6a7b9db6cb043e488 Mon Sep 17 00:00:00 2001 From: Ronja Date: Wed, 9 Sep 2026 11:47:09 +0200 Subject: [PATCH 5/8] feat(cat): use TanStack Query for API state --- t29-project-1/package-lock.json | 27 ++++++++++++++ t29-project-1/package.json | 1 + t29-project-1/src/api/catApi.ts | 30 +++++++++++++++ t29-project-1/src/components/Cat.tsx | 55 ++++++++++------------------ t29-project-1/src/docs/CAT_API.md | 19 ++++++++++ t29-project-1/src/main.tsx | 26 +++++++++---- 6 files changed, 115 insertions(+), 43 deletions(-) create mode 100644 t29-project-1/src/api/catApi.ts diff --git a/t29-project-1/package-lock.json b/t29-project-1/package-lock.json index 29971bf..7fa37ac 100644 --- a/t29-project-1/package-lock.json +++ b/t29-project-1/package-lock.json @@ -8,6 +8,7 @@ "name": "t29-project-1", "version": "0.0.0", "dependencies": { + "@tanstack/react-query": "^5.102.8", "cors": "^2.8.6", "dotenv": "^17.4.2", "express": "^5.2.1", @@ -854,6 +855,32 @@ "dev": true, "license": "MIT" }, + "node_modules/@tanstack/query-core": { + "version": "5.102.8", + "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.102.8.tgz", + "integrity": "sha512-ZNjkJ33CqvPNec/6lZBnHqLc3EVGPZ9ySLhYahU9TcuRFdmwXewuj0c4hwSWcGHqEUwcSrKeZ+oGcvPBqXcQcg==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, + "node_modules/@tanstack/react-query": { + "version": "5.102.8", + "resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.102.8.tgz", + "integrity": "sha512-TYBea4OuXWD7MhaSHq069TWbFe7rcwWN6kzT7JF0OKi1K6c1gTv2IzD6A6ExJsCMozdkqBWeuIUZmu4KQg0O5A==", + "license": "MIT", + "dependencies": { + "@tanstack/query-core": "5.102.8" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^18 || ^19" + } + }, "node_modules/@types/esrecurse": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/@types/esrecurse/-/esrecurse-4.3.1.tgz", diff --git a/t29-project-1/package.json b/t29-project-1/package.json index 9a60a95..6c24560 100644 --- a/t29-project-1/package.json +++ b/t29-project-1/package.json @@ -23,6 +23,7 @@ ] }, "dependencies": { + "@tanstack/react-query": "^5.102.8", "cors": "^2.8.6", "dotenv": "^17.4.2", "express": "^5.2.1", diff --git a/t29-project-1/src/api/catApi.ts b/t29-project-1/src/api/catApi.ts new file mode 100644 index 0000000..72e79bd --- /dev/null +++ b/t29-project-1/src/api/catApi.ts @@ -0,0 +1,30 @@ +export type CatData = { + url?: string; + id?: string; + width?: number; + height?: number; +}; + +export type CatFilters = { + breedId?: string; +}; + +export async function fetchCat({ breedId }: CatFilters = {}): Promise { + const API_BASE = + (import.meta.env.VITE_API_BASE as string) || 'http://localhost:3001'; + const params = new URLSearchParams(); + const selectedBreedId = breedId?.trim(); + + if (selectedBreedId) params.set('breed_ids', selectedBreedId); + + const query = params.toString(); + const response = await fetch( + `${API_BASE}/api/cat${query ? `?${query}` : ''}` + ); + + if (!response.ok) { + throw new Error(`Request failed with status ${response.status}`); + } + + return response.json() as Promise; +} diff --git a/t29-project-1/src/components/Cat.tsx b/t29-project-1/src/components/Cat.tsx index 932d7da..797b21f 100644 --- a/t29-project-1/src/components/Cat.tsx +++ b/t29-project-1/src/components/Cat.tsx @@ -1,37 +1,20 @@ -import { useState } from 'react' +import { useQuery } from '@tanstack/react-query'; +import { fetchCat } from '../api/catApi'; -// Defines the type for the cat object returned by the API -type CatData = { url?: string; id?: string; width?: number; height?: number } -type CatFilters = { breedId?: string } +type CatProps = { breedId?: string }; // Component that fetches and displays a random cat image from the API -export default function Cat() { - // define state variables for the cat object, loading status, and error message - const [cat, setCat] = useState(null) - const [loading, setLoading] = useState(false) - const [error, setError] = useState(null) - - // Function that fetches a random cat image from the API - async function fetchCat(filters: CatFilters = {}) { - setLoading(true) - setError(null) - // Read API_BASE from environment variables, fallback to localhost if not defined - try { - const API_BASE = (import.meta.env.VITE_API_BASE as string) || 'http://localhost:3001' - const params = new URLSearchParams() - const selectedBreedId = filters.breedId?.trim() - if (selectedBreedId) params.set('breed_ids', selectedBreedId) - const query = params.toString() - const res = await fetch(`${API_BASE}/api/cat${query ? `?${query}` : ''}`) - if (!res.ok) throw new Error(`Status ${res.status}`) - const data = await res.json() - setCat(data) - } catch (e: any) { - setError(e?.message || 'Failed to fetch') - } finally { - setLoading(false) - } - } +export default function Cat({ breedId }: CatProps) { + const { + data: cat, + error, + isFetching, + refetch, + } = useQuery({ + queryKey: ['cat', breedId ?? 'all'], + queryFn: () => fetchCat({ breedId }), + enabled: false, + }); // Return JSX: button to fetch a cat, show error if any, and display the cat image when available return ( @@ -39,17 +22,17 @@ export default function Cat() { - {error &&
{error}
} + {error &&
{error.message}
} {cat?.url && (
Random cat
)}
- ) + ); } diff --git a/t29-project-1/src/docs/CAT_API.md b/t29-project-1/src/docs/CAT_API.md index fca77ef..79590ec 100644 --- a/t29-project-1/src/docs/CAT_API.md +++ b/t29-project-1/src/docs/CAT_API.md @@ -25,6 +25,25 @@ const response = await fetch('/api/cat'); const cat = await response.json(); ``` +In the React application, API state is handled with TanStack Query. The +`QueryClientProvider` is configured in `src/main.tsx`, and the `Cat` component +uses a disabled query that is explicitly refetched when the user clicks the +button. This avoids fetching until the user asks for a cat while still letting +TanStack Query manage data, loading, error, caching, and refetch state. + +The query follows this pattern: + +```tsx +const { data, error, isFetching, refetch } = useQuery({ + queryKey: ['cat', breedId ?? 'all'], + queryFn: () => fetchCat({ breedId }), + enabled: false, +}); +``` + +The query key includes the optional breed ID. This ensures that different +filters have separate cache entries when a filter control is added later. + The endpoint returns one cat image object: ```json diff --git a/t29-project-1/src/main.tsx b/t29-project-1/src/main.tsx index bef5202..8aff03e 100644 --- a/t29-project-1/src/main.tsx +++ b/t29-project-1/src/main.tsx @@ -1,10 +1,22 @@ -import { StrictMode } from 'react' -import { createRoot } from 'react-dom/client' -import './index.css' -import App from './App.tsx' +import { StrictMode } from 'react'; +import { createRoot } from 'react-dom/client'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import './index.css'; +import App from './App.tsx'; + +const queryClient = new QueryClient({ + defaultOptions: { + queries: { + retry: false, + staleTime: 30_000, + }, + }, +}); createRoot(document.getElementById('root')!).render( - - , -) + + + + +); From dd53938263d12af3c5635251edb38f10baba9c32 Mon Sep 17 00:00:00 2001 From: Ronja Date: Wed, 9 Sep 2026 11:59:10 +0200 Subject: [PATCH 6/8] test(api): add mocked Cat API tests --- t29-project-1/server/catApi.js | 56 +++++++++++++++++++ t29-project-1/server/catApi.test.js | 83 +++++++++++++++++++++++++++++ t29-project-1/server/index.js | 49 +++-------------- t29-project-1/vite.config.ts | 8 +-- 4 files changed, 151 insertions(+), 45 deletions(-) create mode 100644 t29-project-1/server/catApi.js create mode 100644 t29-project-1/server/catApi.test.js diff --git a/t29-project-1/server/catApi.js b/t29-project-1/server/catApi.js new file mode 100644 index 0000000..acb17d9 --- /dev/null +++ b/t29-project-1/server/catApi.js @@ -0,0 +1,56 @@ +import dotenv from 'dotenv'; + +dotenv.config(); + +const CAT_API_URL = 'https://api.thecatapi.com/v1/images/search'; +const CAT_BREEDS_URL = 'https://api.thecatapi.com/v1/breeds'; +const API_KEY = process.env.CAT_API_KEY; +const BREED_IDS_PATTERN = /^[a-z0-9]+(?:,[a-z0-9]+)*$/i; +const apiHeaders = API_KEY ? { 'x-api-key': API_KEY } : {}; + +function createApiError(message, statusCode) { + const error = new Error(message); + error.statusCode = statusCode; + return error; +} + +export function validateBreedIds(breedIds) { + const selectedBreedIds = typeof breedIds === 'string' ? breedIds.trim() : ''; + + if (selectedBreedIds && !BREED_IDS_PATTERN.test(selectedBreedIds)) { + throw createApiError('Invalid breed_ids filter', 400); + } + + return selectedBreedIds; +} + +async function fetchApiResponse(url) { + const response = await fetch(url, { headers: apiHeaders }); + + if (!response.ok) { + const text = await response.text(); + throw createApiError( + text || `Cat API request failed with status ${response.status}`, + response.status + ); + } + + return response.json(); +} + +export async function fetchCatFromApi(breedIds) { + const selectedBreedIds = validateBreedIds(breedIds); + const catUrl = new URL(CAT_API_URL); + catUrl.searchParams.set('limit', '1'); + + if (selectedBreedIds) catUrl.searchParams.set('breed_ids', selectedBreedIds); + + const data = await fetchApiResponse(catUrl); + return data[0] || {}; +} + +export async function fetchBreedsFromApi() { + const breedsUrl = new URL(CAT_BREEDS_URL); + breedsUrl.searchParams.set('limit', '10'); + return fetchApiResponse(breedsUrl); +} diff --git a/t29-project-1/server/catApi.test.js b/t29-project-1/server/catApi.test.js new file mode 100644 index 0000000..7a6cde7 --- /dev/null +++ b/t29-project-1/server/catApi.test.js @@ -0,0 +1,83 @@ +import { afterEach, describe, expect, it, vi } from 'vitest'; +import { + fetchBreedsFromApi, + fetchCatFromApi, + validateBreedIds, +} from './catApi.js'; + +const fetchMock = vi.fn(); + +vi.stubGlobal('fetch', fetchMock); + +function mockResponse(data, { ok = true, status = 200, text = '' } = {}) { + return { + ok, + status, + json: vi.fn().mockResolvedValue(data), + text: vi.fn().mockResolvedValue(text), + }; +} + +afterEach(() => { + fetchMock.mockReset(); +}); + +describe('validateBreedIds', () => { + it('accepts one or more comma-separated breed IDs', () => { + expect(validateBreedIds(' beng,siam ')).toBe('beng,siam'); + expect(validateBreedIds()).toBe(''); + }); + + it('rejects invalid breed IDs', () => { + expect(() => validateBreedIds('beng siam')).toThrow( + 'Invalid breed_ids filter' + ); + }); +}); + +describe('fetchCatFromApi', () => { + it('fetches one random cat without a breed filter', async () => { + const cat = { id: 'cat-1', url: 'https://example.com/cat.jpg' }; + fetchMock.mockResolvedValue(mockResponse([cat])); + + await expect(fetchCatFromApi()).resolves.toEqual(cat); + + const requestUrl = new URL(String(fetchMock.mock.calls[0][0])); + expect(requestUrl.pathname).toBe('/v1/images/search'); + expect(requestUrl.searchParams.get('limit')).toBe('1'); + expect(requestUrl.searchParams.has('breed_ids')).toBe(false); + }); + + it('adds the breed filter to the request', async () => { + fetchMock.mockResolvedValue(mockResponse([{ id: 'cat-2' }])); + + await fetchCatFromApi('beng,siam'); + + const requestUrl = new URL(String(fetchMock.mock.calls[0][0])); + expect(requestUrl.searchParams.get('breed_ids')).toBe('beng,siam'); + }); + + it('propagates upstream API errors', async () => { + fetchMock.mockResolvedValue( + mockResponse(null, { ok: false, status: 429, text: 'Too many requests' }) + ); + + await expect(fetchCatFromApi()).rejects.toMatchObject({ + message: 'Too many requests', + statusCode: 429, + }); + }); +}); + +describe('fetchBreedsFromApi', () => { + it('requests up to ten breeds', async () => { + const breeds = [{ id: 'abys', name: 'Abyssinian' }]; + fetchMock.mockResolvedValue(mockResponse(breeds)); + + await expect(fetchBreedsFromApi()).resolves.toEqual(breeds); + + const requestUrl = new URL(String(fetchMock.mock.calls[0][0])); + expect(requestUrl.pathname).toBe('/v1/breeds'); + expect(requestUrl.searchParams.get('limit')).toBe('10'); + }); +}); diff --git a/t29-project-1/server/index.js b/t29-project-1/server/index.js index 2ec0127..7064f98 100644 --- a/t29-project-1/server/index.js +++ b/t29-project-1/server/index.js @@ -1,8 +1,6 @@ -import dotenv from 'dotenv'; import express from 'express'; import cors from 'cors'; - -dotenv.config(); +import { fetchBreedsFromApi, fetchCatFromApi } from './catApi.js'; // Create an Express application const app = express(); @@ -10,57 +8,26 @@ const app = express(); //cors is a middleware that allows cross-origin requests from the frontend to the backend app.use(cors()); -const CAT_API_URL = 'https://api.thecatapi.com/v1/images/search'; -const CAT_BREEDS_URL = 'https://api.thecatapi.com/v1/breeds'; -const API_KEY = process.env.CAT_API_KEY; -const BREED_IDS_PATTERN = /^[a-z0-9]+(?:,[a-z0-9]+)*$/i; - -const apiHeaders = API_KEY ? { 'x-api-key': API_KEY } : {}; - app.get('/api/breeds', async (req, res) => { try { - const breedsUrl = new URL(CAT_BREEDS_URL); - breedsUrl.searchParams.set('limit', '10'); - const response = await fetch(breedsUrl, { headers: apiHeaders }); - if (!response.ok) { - const text = await response.text(); - return res.status(response.status).send(text); - } - const data = await response.json(); - res.json(data); + res.json(await fetchBreedsFromApi()); } catch (err) { console.error(err); - res.status(500).json({ error: 'failed to fetch breeds' }); + res.status(err.statusCode || 500).send(err.message); } }); // Define a route to fetch a random cat image from the Cat API app.get('/api/cat', async (req, res) => { try { - const breedIds = typeof req.query.breed_ids === 'string' ? req.query.breed_ids.trim() : ''; - if (breedIds && !BREED_IDS_PATTERN.test(breedIds)) { - return res.status(400).json({ error: 'Invalid breed_ids filter' }); - } - - const searchUrl = new URL(CAT_API_URL); - searchUrl.searchParams.set('limit', '1'); - if (breedIds) searchUrl.searchParams.set('breed_ids', breedIds); - - // If an API key is provided, include it in the request headers - // Fetch a random cat image from the Cat API - const response = await fetch(searchUrl, { headers: apiHeaders }); - // If the response is not OK, return the error message and status code - if (!response.ok) { - const text = await response.text(); - return res.status(response.status).send(text); - } - const data = await response.json(); - res.json(data[0] || {}); + res.json(await fetchCatFromApi(req.query.breed_ids)); } catch (err) { console.error(err); - res.status(500).json({ error: 'failed to fetch cat' }); + res.status(err.statusCode || 500).send(err.message); } }); const port = process.env.PORT || 3001; -app.listen(port, () => console.log(`Cat API proxy running on http://localhost:${port}`)); +app.listen(port, () => + console.log(`Cat API proxy running on http://localhost:${port}`) +); diff --git a/t29-project-1/vite.config.ts b/t29-project-1/vite.config.ts index 1b9d5b9..ebe62b0 100644 --- a/t29-project-1/vite.config.ts +++ b/t29-project-1/vite.config.ts @@ -1,12 +1,12 @@ -import react from '@vitejs/plugin-react' -import { defineConfig } from 'vitest/config' +import react from '@vitejs/plugin-react'; +import { defineConfig } from 'vitest/config'; // https://vite.dev/config/ export default defineConfig({ plugins: [react()], test: { environment: 'node', - include: ['src/**/*.test.ts', 'src/**/*.test.tsx'], + include: ['src/**/*.test.ts', 'src/**/*.test.tsx', 'server/**/*.test.js'], }, server: { proxy: { @@ -17,4 +17,4 @@ export default defineConfig({ }, }, }, -}) +}); From 76169019aa676f15a55ee75b5217fd2ebb047308 Mon Sep 17 00:00:00 2001 From: Ronja Date: Wed, 9 Sep 2026 12:21:52 +0200 Subject: [PATCH 7/8] docs(test): add testing guide --- t29-project-1/src/docs/TESTING.md | 88 +++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 t29-project-1/src/docs/TESTING.md diff --git a/t29-project-1/src/docs/TESTING.md b/t29-project-1/src/docs/TESTING.md new file mode 100644 index 0000000..d883356 --- /dev/null +++ b/t29-project-1/src/docs/TESTING.md @@ -0,0 +1,88 @@ +# Testing guide + +This project uses Vitest for automated tests. + +## Run the tests + +Run all tests once from the `t29-project-1` folder: + +```bash +npm test +``` + +Run Vitest in watch mode while developing: + +```bash +npm run test:watch +``` + +The test configuration is in `vite.config.ts`. It includes tests under `src/` +and backend tests under `server/`. + +## What is tested now + +The current tests focus on the Cat API server logic. They are located in: + +```text +server/catApi.test.js +``` + +The tests cover: + +- Valid breed ID values. +- Rejection of invalid `breed_ids` values. +- Fetching one random cat with `limit=1`. +- Adding the optional `breed_ids` filter to a request. +- Fetching up to 10 breeds. +- Forwarding errors from The Cat API. + +## Mocking API requests + +Tests must not depend on the real Cat API. The tests replace the global +`fetch` function with a Vitest mock: + +```js +const fetchMock = vi.fn(); +vi.stubGlobal('fetch', fetchMock); +``` + +Each test provides a mocked response and resets the mock afterwards. This keeps +the tests fast and deterministic, and prevents external API calls during CI. + +## Server structure + +The API logic is separated from the Express routes: + +- `server/catApi.js` contains the testable Cat API functions. +- `server/index.js` contains the Express routes and HTTP responses. +- `server/catApi.test.js` tests the Cat API functions with mocked `fetch`. + +This separation makes it possible to test the API behavior without starting a +server or using a real network connection. + +## Adding a backend API test + +Add a test to `server/catApi.test.js` or create another file matching +`server/**/*.test.js`: + +```js +it('describes the expected API behavior', async () => { + fetchMock.mockResolvedValue(mockResponse([{ id: 'cat-1' }])); + + await expect(fetchCatFromApi()).resolves.toEqual({ id: 'cat-1' }); +}); +``` + +Tests should check behavior and request parameters rather than implementation +details. + +## Current test limitations + +The following test types are planned but are not implemented yet: + +- React component interaction tests. +- TanStack Query behavior tests in the UI. +- Snapshot tests. +- Browser and mobile device testing. + +UI tests should be added separately from the backend tests when that work starts. From f0bb35854b15fc9714f5358cfae77285387ae458 Mon Sep 17 00:00:00 2001 From: Ronja Date: Wed, 9 Sep 2026 14:21:06 +0200 Subject: [PATCH 8/8] style: format test templates --- t29-project-1/src/tests/template.test.ts | 6 +++--- t29-project-1/src/tests/vitest-setup.test.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/t29-project-1/src/tests/template.test.ts b/t29-project-1/src/tests/template.test.ts index b595fc5..07b620b 100644 --- a/t29-project-1/src/tests/template.test.ts +++ b/t29-project-1/src/tests/template.test.ts @@ -1,6 +1,6 @@ -import { describe, it } from 'vitest' +import { describe, it } from 'vitest'; // Template for creating new Vitest tests. describe('Feature name', () => { - it.todo('add a test') -}) \ No newline at end of file + it.todo('add a test'); +}); diff --git a/t29-project-1/src/tests/vitest-setup.test.ts b/t29-project-1/src/tests/vitest-setup.test.ts index cd3f642..4e899f8 100644 --- a/t29-project-1/src/tests/vitest-setup.test.ts +++ b/t29-project-1/src/tests/vitest-setup.test.ts @@ -1,7 +1,7 @@ -import { describe, expect, it } from 'vitest' +import { describe, expect, it } from 'vitest'; // This test file is used to verify that the Vitest testing framework is set up correctly in the project. It includes a simple test case that checks if the addition of 1 and 1 equals 2. describe('Vitest setup', () => { it('runs a basic assertion', () => { - expect(1 + 1).toBe(2) - }) -}) \ No newline at end of file + expect(1 + 1).toBe(2); + }); +});