From 98d6dfb6db22747db600fac5994c61e21f3b6f76 Mon Sep 17 00:00:00 2001 From: xion Date: Sun, 11 May 2025 19:20:51 +0800 Subject: [PATCH] feat: add upload --- package.json | 20 +- pnpm-lock.yaml | 364 +++++++++++++++++++---------------- src/module/index.ts | 2 +- src/module/proxy/ai-proxy.ts | 84 +++++++- 4 files changed, 286 insertions(+), 184 deletions(-) diff --git a/package.json b/package.json index 743e8d7..f64254b 100644 --- a/package.json +++ b/package.json @@ -35,26 +35,28 @@ "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^16.0.1", "@rollup/plugin-typescript": "^12.1.2", + "@types/busboy": "^1.5.4", "@types/http-proxy": "^1.17.16", - "@types/node": "^22.13.14", + "@types/node": "^22.15.17", "@types/send": "^0.17.4", "concurrently": "^9.1.2", "cross-env": "^7.0.3", - "nodemon": "^3.1.9", - "rollup": "^4.38.0", + "nodemon": "^3.1.10", + "rollup": "^4.40.2", "tslib": "^2.8.1", - "typescript": "^5.8.2" + "typescript": "^5.8.3" }, "dependencies": { - "@kevisual/code-center-module": "0.0.16", + "@kevisual/code-center-module": "0.0.18", "@kevisual/permission": "^0.0.1", - "@kevisual/query": "^0.0.15", + "@kevisual/query": "^0.0.17", "@kevisual/query-config": "^0.0.2", - "@kevisual/router": "0.0.9", - "@kevisual/use-config": "^1.0.10", + "@kevisual/router": "0.0.13", + "@kevisual/use-config": "^1.0.15", "archiver": "^7.0.1", + "busboy": "^1.6.0", "cookie": "^1.0.2", - "ioredis": "^5.6.0", + "ioredis": "^5.6.1", "minio": "^8.0.5", "nanoid": "^5.1.5", "send": "^1.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e21759b..c79b918 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,32 +12,35 @@ importers: .: dependencies: '@kevisual/code-center-module': - specifier: 0.0.16 - version: 0.0.16(@kevisual/auth@1.0.5)(@kevisual/router@0.0.9)(@kevisual/use-config@1.0.10(dotenv@16.4.7))(ioredis@5.6.0)(pg@8.13.3)(sequelize@6.37.7(pg@8.13.3)) + specifier: 0.0.18 + version: 0.0.18(@kevisual/auth@1.0.5)(@kevisual/router@0.0.13)(@kevisual/use-config@1.0.15(dotenv@16.4.7))(ioredis@5.6.1)(pg@8.13.3)(sequelize@6.37.7(pg@8.13.3)) '@kevisual/permission': specifier: ^0.0.1 version: 0.0.1 '@kevisual/query': - specifier: ^0.0.15 - version: 0.0.15(ws@8.18.0)(zod@3.24.2) + specifier: ^0.0.17 + version: 0.0.17(ws@8.18.0)(zod@3.24.2) '@kevisual/query-config': specifier: ^0.0.2 - version: 0.0.2(@kevisual/query@0.0.15(ws@8.18.0)(zod@3.24.2)) + version: 0.0.2(@kevisual/query@0.0.17(ws@8.18.0)(zod@3.24.2)) '@kevisual/router': - specifier: 0.0.9 - version: 0.0.9 + specifier: 0.0.13 + version: 0.0.13 '@kevisual/use-config': - specifier: ^1.0.10 - version: 1.0.10(dotenv@16.4.7) + specifier: ^1.0.15 + version: 1.0.15(dotenv@16.4.7) archiver: specifier: ^7.0.1 version: 7.0.1 + busboy: + specifier: ^1.6.0 + version: 1.6.0 cookie: specifier: ^1.0.2 version: 1.0.2 ioredis: - specifier: ^5.6.0 - version: 5.6.0 + specifier: ^5.6.1 + version: 5.6.1 minio: specifier: ^8.0.5 version: 8.0.5 @@ -53,22 +56,25 @@ importers: devDependencies: '@rollup/plugin-commonjs': specifier: ^28.0.3 - version: 28.0.3(rollup@4.38.0) + version: 28.0.3(rollup@4.40.2) '@rollup/plugin-json': specifier: ^6.1.0 - version: 6.1.0(rollup@4.38.0) + version: 6.1.0(rollup@4.40.2) '@rollup/plugin-node-resolve': specifier: ^16.0.1 - version: 16.0.1(rollup@4.38.0) + version: 16.0.1(rollup@4.40.2) '@rollup/plugin-typescript': specifier: ^12.1.2 - version: 12.1.2(rollup@4.38.0)(tslib@2.8.1)(typescript@5.8.2) + version: 12.1.2(rollup@4.40.2)(tslib@2.8.1)(typescript@5.8.3) + '@types/busboy': + specifier: ^1.5.4 + version: 1.5.4 '@types/http-proxy': specifier: ^1.17.16 version: 1.17.16 '@types/node': - specifier: ^22.13.14 - version: 22.13.14 + specifier: ^22.15.17 + version: 22.15.17 '@types/send': specifier: ^0.17.4 version: 0.17.4 @@ -79,17 +85,17 @@ importers: specifier: ^7.0.3 version: 7.0.3 nodemon: - specifier: ^3.1.9 - version: 3.1.9 + specifier: ^3.1.10 + version: 3.1.10 rollup: - specifier: ^4.38.0 - version: 4.38.0 + specifier: ^4.40.2 + version: 4.40.2 tslib: specifier: ^2.8.1 version: 2.8.1 typescript: - specifier: ^5.8.2 - version: 5.8.2 + specifier: ^5.8.3 + version: 5.8.3 packages: @@ -106,8 +112,8 @@ packages: '@kevisual/auth@1.0.5': resolution: {integrity: sha512-GwsLj7unKXi7lmMiIIgdig4LwwLiDJnOy15HHZR5gMbyK6s5/uJiMY5RXPB2+onGzTNDqFo/hXjsD2wkerHPVg==} - '@kevisual/code-center-module@0.0.16': - resolution: {integrity: sha512-RmS6c7B3potQFPCmFXZoxCAWmiHdsp/D2TKSsGBU0ewVdhgts1KItYNoatIa7Yoy2mfwKG33rYMw+OUgUlHaQQ==} + '@kevisual/code-center-module@0.0.18': + resolution: {integrity: sha512-BfANmxLEO1AwVmqpa6VDgxk//YN8asf1r5jIPpyKDQm12kyyrYgHND9AgGCDRH8lvq6rYVe0svCZXD5b06UPWQ==} peerDependencies: '@kevisual/auth': ^1.0.5 '@kevisual/router': ^0.0.7 @@ -116,8 +122,8 @@ packages: pg: ^8.13.3 sequelize: ^6.37.5 - '@kevisual/load@0.0.4': - resolution: {integrity: sha512-TJBieKsEoEPfP4+tDyhNZdMX2LMAGiDZ/IrAXPFWB4jeFP0Ywm1W5xDV52LhhHq4nwTmuhyTVmPxJYiEVYTHtA==} + '@kevisual/load@0.0.6': + resolution: {integrity: sha512-+3YTFehRcZ1haGel5DKYMUwmi5i6f2psyaPZlfkKU/cOXgkpwoG9/BEqPCnPjicKqqnksEpixVRkyHJ+5bjLVA==} '@kevisual/permission@0.0.1': resolution: {integrity: sha512-nSX2LzbPkU3YAMegbUFGU8tfmtFb7dcF5edqzm+gI6crcyCL1JzIB9HAYNEeEVIljLxuREwM/vVg9aFmF4cz9Q==} @@ -127,14 +133,14 @@ packages: peerDependencies: '@kevisual/query': ^0.0.13 - '@kevisual/query@0.0.15': - resolution: {integrity: sha512-DK41qvyOiJMmlj70QyVP/48M0gszA39DdnBLtgU94YwAe6OqKrr9tYXHLjZrOROmUVMezIIBQuWMLedSAvb54A==} + '@kevisual/query@0.0.17': + resolution: {integrity: sha512-WMvWM+3pNlPKNhoxPX9fldMp1tOeJrkRM/tXA4bvOnftIoX2yeI4v0wTpbGJXES/bLlo7OC2kV8SeKF0K6dnxQ==} - '@kevisual/router@0.0.9': - resolution: {integrity: sha512-qPyC2GVJ7iOIdJCCKNDsWMAKOQeSJW9HBpL5ZWKHTbi+t4jJBGTzIlXmjKeMHRd0lr/Qq1imQvlkSh4hlrbodA==} + '@kevisual/router@0.0.13': + resolution: {integrity: sha512-raji8aKXr0jigmJVOKBXb5gpstiAuyoIDy9m6SyPf4lRjCU3pspVI1bpscOUCBlaPICo6TLzPQxXhyTvvvtdWw==} - '@kevisual/use-config@1.0.10': - resolution: {integrity: sha512-fH2B4BnR4+OjR3PzAegF8H9RJpyFZu6BnVDyfvSSZavZMurufkJ949jizoRde+bNAHff/PRcpa5EZg2imZNf1g==} + '@kevisual/use-config@1.0.15': + resolution: {integrity: sha512-bLWdGMOPHgIKV4qY3U18cLoOKmSBL72K1wL0MneyEsqj9jRXoc98OMMyQm2/BlBddFTL1olOfByRET2DvwmWAA==} peerDependencies: dotenv: ^16.4.7 @@ -191,109 +197,112 @@ packages: rollup: optional: true - '@rollup/rollup-android-arm-eabi@4.38.0': - resolution: {integrity: sha512-ldomqc4/jDZu/xpYU+aRxo3V4mGCV9HeTgUBANI3oIQMOL+SsxB+S2lxMpkFp5UamSS3XuTMQVbsS24R4J4Qjg==} + '@rollup/rollup-android-arm-eabi@4.40.2': + resolution: {integrity: sha512-JkdNEq+DFxZfUwxvB58tHMHBHVgX23ew41g1OQinthJ+ryhdRk67O31S7sYw8u2lTjHUPFxwar07BBt1KHp/hg==} cpu: [arm] os: [android] - '@rollup/rollup-android-arm64@4.38.0': - resolution: {integrity: sha512-VUsgcy4GhhT7rokwzYQP+aV9XnSLkkhlEJ0St8pbasuWO/vwphhZQxYEKUP3ayeCYLhk6gEtacRpYP/cj3GjyQ==} + '@rollup/rollup-android-arm64@4.40.2': + resolution: {integrity: sha512-13unNoZ8NzUmnndhPTkWPWbX3vtHodYmy+I9kuLxN+F+l+x3LdVF7UCu8TWVMt1POHLh6oDHhnOA04n8oJZhBw==} cpu: [arm64] os: [android] - '@rollup/rollup-darwin-arm64@4.38.0': - resolution: {integrity: sha512-buA17AYXlW9Rn091sWMq1xGUvWQFOH4N1rqUxGJtEQzhChxWjldGCCup7r/wUnaI6Au8sKXpoh0xg58a7cgcpg==} + '@rollup/rollup-darwin-arm64@4.40.2': + resolution: {integrity: sha512-Gzf1Hn2Aoe8VZzevHostPX23U7N5+4D36WJNHK88NZHCJr7aVMG4fadqkIf72eqVPGjGc0HJHNuUaUcxiR+N/w==} cpu: [arm64] os: [darwin] - '@rollup/rollup-darwin-x64@4.38.0': - resolution: {integrity: sha512-Mgcmc78AjunP1SKXl624vVBOF2bzwNWFPMP4fpOu05vS0amnLcX8gHIge7q/lDAHy3T2HeR0TqrriZDQS2Woeg==} + '@rollup/rollup-darwin-x64@4.40.2': + resolution: {integrity: sha512-47N4hxa01a4x6XnJoskMKTS8XZ0CZMd8YTbINbi+w03A2w4j1RTlnGHOz/P0+Bg1LaVL6ufZyNprSg+fW5nYQQ==} cpu: [x64] os: [darwin] - '@rollup/rollup-freebsd-arm64@4.38.0': - resolution: {integrity: sha512-zzJACgjLbQTsscxWqvrEQAEh28hqhebpRz5q/uUd1T7VTwUNZ4VIXQt5hE7ncs0GrF+s7d3S4on4TiXUY8KoQA==} + '@rollup/rollup-freebsd-arm64@4.40.2': + resolution: {integrity: sha512-8t6aL4MD+rXSHHZUR1z19+9OFJ2rl1wGKvckN47XFRVO+QL/dUSpKA2SLRo4vMg7ELA8pzGpC+W9OEd1Z/ZqoQ==} cpu: [arm64] os: [freebsd] - '@rollup/rollup-freebsd-x64@4.38.0': - resolution: {integrity: sha512-hCY/KAeYMCyDpEE4pTETam0XZS4/5GXzlLgpi5f0IaPExw9kuB+PDTOTLuPtM10TlRG0U9OSmXJ+Wq9J39LvAg==} + '@rollup/rollup-freebsd-x64@4.40.2': + resolution: {integrity: sha512-C+AyHBzfpsOEYRFjztcYUFsH4S7UsE9cDtHCtma5BK8+ydOZYgMmWg1d/4KBytQspJCld8ZIujFMAdKG1xyr4Q==} cpu: [x64] os: [freebsd] - '@rollup/rollup-linux-arm-gnueabihf@4.38.0': - resolution: {integrity: sha512-mimPH43mHl4JdOTD7bUMFhBdrg6f9HzMTOEnzRmXbOZqjijCw8LA5z8uL6LCjxSa67H2xiLFvvO67PT05PRKGg==} + '@rollup/rollup-linux-arm-gnueabihf@4.40.2': + resolution: {integrity: sha512-de6TFZYIvJwRNjmW3+gaXiZ2DaWL5D5yGmSYzkdzjBDS3W+B9JQ48oZEsmMvemqjtAFzE16DIBLqd6IQQRuG9Q==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm-musleabihf@4.38.0': - resolution: {integrity: sha512-tPiJtiOoNuIH8XGG8sWoMMkAMm98PUwlriOFCCbZGc9WCax+GLeVRhmaxjJtz6WxrPKACgrwoZ5ia/uapq3ZVg==} + '@rollup/rollup-linux-arm-musleabihf@4.40.2': + resolution: {integrity: sha512-urjaEZubdIkacKc930hUDOfQPysezKla/O9qV+O89enqsqUmQm8Xj8O/vh0gHg4LYfv7Y7UsE3QjzLQzDYN1qg==} cpu: [arm] os: [linux] - '@rollup/rollup-linux-arm64-gnu@4.38.0': - resolution: {integrity: sha512-wZco59rIVuB0tjQS0CSHTTUcEde+pXQWugZVxWaQFdQQ1VYub/sTrNdY76D1MKdN2NB48JDuGABP6o6fqos8mA==} + '@rollup/rollup-linux-arm64-gnu@4.40.2': + resolution: {integrity: sha512-KlE8IC0HFOC33taNt1zR8qNlBYHj31qGT1UqWqtvR/+NuCVhfufAq9fxO8BMFC22Wu0rxOwGVWxtCMvZVLmhQg==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-arm64-musl@4.38.0': - resolution: {integrity: sha512-fQgqwKmW0REM4LomQ+87PP8w8xvU9LZfeLBKybeli+0yHT7VKILINzFEuggvnV9M3x1Ed4gUBmGUzCo/ikmFbQ==} + '@rollup/rollup-linux-arm64-musl@4.40.2': + resolution: {integrity: sha512-j8CgxvfM0kbnhu4XgjnCWJQyyBOeBI1Zq91Z850aUddUmPeQvuAy6OiMdPS46gNFgy8gN1xkYyLgwLYZG3rBOg==} cpu: [arm64] os: [linux] - '@rollup/rollup-linux-loongarch64-gnu@4.38.0': - resolution: {integrity: sha512-hz5oqQLXTB3SbXpfkKHKXLdIp02/w3M+ajp8p4yWOWwQRtHWiEOCKtc9U+YXahrwdk+3qHdFMDWR5k+4dIlddg==} + '@rollup/rollup-linux-loongarch64-gnu@4.40.2': + resolution: {integrity: sha512-Ybc/1qUampKuRF4tQXc7G7QY9YRyeVSykfK36Y5Qc5dmrIxwFhrOzqaVTNoZygqZ1ZieSWTibfFhQ5qK8jpWxw==} cpu: [loong64] os: [linux] - '@rollup/rollup-linux-powerpc64le-gnu@4.38.0': - resolution: {integrity: sha512-NXqygK/dTSibQ+0pzxsL3r4Xl8oPqVoWbZV9niqOnIHV/J92fe65pOir0xjkUZDRSPyFRvu+4YOpJF9BZHQImw==} + '@rollup/rollup-linux-powerpc64le-gnu@4.40.2': + resolution: {integrity: sha512-3FCIrnrt03CCsZqSYAOW/k9n625pjpuMzVfeI+ZBUSDT3MVIFDSPfSUgIl9FqUftxcUXInvFah79hE1c9abD+Q==} cpu: [ppc64] os: [linux] - '@rollup/rollup-linux-riscv64-gnu@4.38.0': - resolution: {integrity: sha512-GEAIabR1uFyvf/jW/5jfu8gjM06/4kZ1W+j1nWTSSB3w6moZEBm7iBtzwQ3a1Pxos2F7Gz+58aVEnZHU295QTg==} + '@rollup/rollup-linux-riscv64-gnu@4.40.2': + resolution: {integrity: sha512-QNU7BFHEvHMp2ESSY3SozIkBPaPBDTsfVNGx3Xhv+TdvWXFGOSH2NJvhD1zKAT6AyuuErJgbdvaJhYVhVqrWTg==} cpu: [riscv64] os: [linux] - '@rollup/rollup-linux-riscv64-musl@4.38.0': - resolution: {integrity: sha512-9EYTX+Gus2EGPbfs+fh7l95wVADtSQyYw4DfSBcYdUEAmP2lqSZY0Y17yX/3m5VKGGJ4UmIH5LHLkMJft3bYoA==} + '@rollup/rollup-linux-riscv64-musl@4.40.2': + resolution: {integrity: sha512-5W6vNYkhgfh7URiXTO1E9a0cy4fSgfE4+Hl5agb/U1sa0kjOLMLC1wObxwKxecE17j0URxuTrYZZME4/VH57Hg==} cpu: [riscv64] os: [linux] - '@rollup/rollup-linux-s390x-gnu@4.38.0': - resolution: {integrity: sha512-Mpp6+Z5VhB9VDk7RwZXoG2qMdERm3Jw07RNlXHE0bOnEeX+l7Fy4bg+NxfyN15ruuY3/7Vrbpm75J9QHFqj5+Q==} + '@rollup/rollup-linux-s390x-gnu@4.40.2': + resolution: {integrity: sha512-B7LKIz+0+p348JoAL4X/YxGx9zOx3sR+o6Hj15Y3aaApNfAshK8+mWZEf759DXfRLeL2vg5LYJBB7DdcleYCoQ==} cpu: [s390x] os: [linux] - '@rollup/rollup-linux-x64-gnu@4.38.0': - resolution: {integrity: sha512-vPvNgFlZRAgO7rwncMeE0+8c4Hmc+qixnp00/Uv3ht2x7KYrJ6ERVd3/R0nUtlE6/hu7/HiiNHJ/rP6knRFt1w==} + '@rollup/rollup-linux-x64-gnu@4.40.2': + resolution: {integrity: sha512-lG7Xa+BmBNwpjmVUbmyKxdQJ3Q6whHjMjzQplOs5Z+Gj7mxPtWakGHqzMqNER68G67kmCX9qX57aRsW5V0VOng==} cpu: [x64] os: [linux] - '@rollup/rollup-linux-x64-musl@4.38.0': - resolution: {integrity: sha512-q5Zv+goWvQUGCaL7fU8NuTw8aydIL/C9abAVGCzRReuj5h30TPx4LumBtAidrVOtXnlB+RZkBtExMsfqkMfb8g==} + '@rollup/rollup-linux-x64-musl@4.40.2': + resolution: {integrity: sha512-tD46wKHd+KJvsmije4bUskNuvWKFcTOIM9tZ/RrmIvcXnbi0YK/cKS9FzFtAm7Oxi2EhV5N2OpfFB348vSQRXA==} cpu: [x64] os: [linux] - '@rollup/rollup-win32-arm64-msvc@4.38.0': - resolution: {integrity: sha512-u/Jbm1BU89Vftqyqbmxdq14nBaQjQX1HhmsdBWqSdGClNaKwhjsg5TpW+5Ibs1mb8Es9wJiMdl86BcmtUVXNZg==} + '@rollup/rollup-win32-arm64-msvc@4.40.2': + resolution: {integrity: sha512-Bjv/HG8RRWLNkXwQQemdsWw4Mg+IJ29LK+bJPW2SCzPKOUaMmPEppQlu/Fqk1d7+DX3V7JbFdbkh/NMmurT6Pg==} cpu: [arm64] os: [win32] - '@rollup/rollup-win32-ia32-msvc@4.38.0': - resolution: {integrity: sha512-mqu4PzTrlpNHHbu5qleGvXJoGgHpChBlrBx/mEhTPpnAL1ZAYFlvHD7rLK839LLKQzqEQMFJfGrrOHItN4ZQqA==} + '@rollup/rollup-win32-ia32-msvc@4.40.2': + resolution: {integrity: sha512-dt1llVSGEsGKvzeIO76HToiYPNPYPkmjhMHhP00T9S4rDern8P2ZWvWAQUEJ+R1UdMWJ/42i/QqJ2WV765GZcA==} cpu: [ia32] os: [win32] - '@rollup/rollup-win32-x64-msvc@4.38.0': - resolution: {integrity: sha512-jjqy3uWlecfB98Psxb5cD6Fny9Fupv9LrDSPTQZUROqjvZmcCqNu4UMl7qqhlUUGpwiAkotj6GYu4SZdcr/nLw==} + '@rollup/rollup-win32-x64-msvc@4.40.2': + resolution: {integrity: sha512-bwspbWB04XJpeElvsp+DCylKfF4trJDa2Y9Go8O6A7YLX2LIKGcNK/CYImJN6ZP4DcuOHB4Utl3iCbnR62DudA==} cpu: [x64] os: [win32] '@socket.io/component-emitter@3.1.2': resolution: {integrity: sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==} + '@types/busboy@1.5.4': + resolution: {integrity: sha512-kG7WrUuAKK0NoyxfQHsVE6j1m01s6kMma64E+OZenQABMQyTJop1DumUWcLwAQ2JzpefU7PDYoRDKl8uZosFjw==} + '@types/cors@2.8.17': resolution: {integrity: sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==} @@ -324,8 +333,8 @@ packages: '@types/node@18.19.86': resolution: {integrity: sha512-fifKayi175wLyKyc5qUfyENhQ1dCNI1UNjp653d8kuYcPQN5JhX3dGuP/XmvPTg/xRBn1VTLpbmi+H/Mr7tLfQ==} - '@types/node@22.13.14': - resolution: {integrity: sha512-Zs/Ollc1SJ8nKUAgc7ivOEdIBM8JAKgrqqUYi2J997JuKO7/tpQC+WCetQ1sypiKCQWHdvdg9wBNpUPEWZae7w==} + '@types/node@22.15.17': + resolution: {integrity: sha512-wIX2aSZL5FE+MR0JlvF87BNVrtFWf6AE6rxSE9X7OwnVvoyCQjpzSRJ+M87se/4QCkCiebQAqrJ0y6fwIyi7nw==} '@types/resolve@1.20.2': resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} @@ -432,6 +441,10 @@ packages: buffer@6.0.3: resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} + busboy@1.6.0: + resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} + engines: {node: '>=10.16.0'} + call-bind-apply-helpers@1.0.2: resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} engines: {node: '>= 0.4'} @@ -756,8 +769,8 @@ packages: inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} - ioredis@5.6.0: - resolution: {integrity: sha512-tBZlIIWbndeWBWCXWZiqtOF/yxf6yZX3tAlTJ7nfo5jhd6dctNxF7QnYlZLZ1a0o0pDoen7CgZqO+zjNaFbJAg==} + ioredis@5.6.1: + resolution: {integrity: sha512-UxC0Yv1Y4WRJiGQxQkP0hfdL0/5/6YvdfOOClRgJ0qppSarkhneSa6UvkMkms0AkdGimSH3Ikqm+6mkMmX7vGA==} engines: {node: '>=12.22.0'} ipaddr.js@2.2.0: @@ -920,8 +933,8 @@ packages: resolution: {integrity: sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==} engines: {node: '>= 6.13.0'} - nodemon@3.1.9: - resolution: {integrity: sha512-hdr1oIb2p6ZSxu3PB2JWWYS7ZQ0qvaZsc3hK8DR8f02kRzc8rjYmxAIvdz+aYC+8F2IjNaB7HMcSDg8nQpJxyg==} + nodemon@3.1.10: + resolution: {integrity: sha512-WDjw3pJ0/0jMFmyNDp3gvY2YizjLmmOUQo6DEBY+JgdvW/yQ9mEeSw6H5ythl5Ny2ytb7f9C2nIbjSxMNzbJXw==} engines: {node: '>=10'} hasBin: true @@ -1080,8 +1093,8 @@ packages: retry-as-promised@7.1.1: resolution: {integrity: sha512-hMD7odLOt3LkTjcif8aRZqi/hybjpLNgSk5oF5FCowfCjok6LukpN2bDX7R5wDmbgBQFn7YoBxSagmtXHaJYJw==} - rollup@4.38.0: - resolution: {integrity: sha512-5SsIRtJy9bf1ErAOiFMFzl64Ex9X5V7bnJ+WlFMb+zmP459OSWCEG7b0ERZ+PEU7xPt4OG3RHbrp1LJlXxYTrw==} + rollup@4.40.2: + resolution: {integrity: sha512-tfUOg6DTP4rhQ3VjOO6B4wyrJnGOX85requAXvqYTHsOgb2TFJdZ3aWpT8W2kPoypSGP7dZUyzxJ9ee4buM5Fg==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true @@ -1210,6 +1223,10 @@ packages: stream-json@1.9.1: resolution: {integrity: sha512-uWkjJ+2Nt/LO9Z/JyKZbMusL8Dkh97uUBTv3AJQ74y07lVahLY4eEFsPsE97pxYBwr8nnjMAIch5eqI0gPShyw==} + streamsearch@1.1.0: + resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} + engines: {node: '>=10.0.0'} + streamx@2.22.0: resolution: {integrity: sha512-sLh1evHOzBy/iWRiR6d1zRcLao4gGZr3C1kzNz4fopCOKJb6xD9ub8Mpi9Mr1R6id5o43S+d93fI48UC5uM9aw==} @@ -1292,8 +1309,8 @@ packages: tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} - typescript@5.8.2: - resolution: {integrity: sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==} + typescript@5.8.3: + resolution: {integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==} engines: {node: '>=14.17'} hasBin: true @@ -1303,8 +1320,8 @@ packages: undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} - undici-types@6.20.0: - resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==} + undici-types@6.21.0: + resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==} util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} @@ -1429,12 +1446,12 @@ snapshots: '@kevisual/auth@1.0.5': {} - '@kevisual/code-center-module@0.0.16(@kevisual/auth@1.0.5)(@kevisual/router@0.0.9)(@kevisual/use-config@1.0.10(dotenv@16.4.7))(ioredis@5.6.0)(pg@8.13.3)(sequelize@6.37.7(pg@8.13.3))': + '@kevisual/code-center-module@0.0.18(@kevisual/auth@1.0.5)(@kevisual/router@0.0.13)(@kevisual/use-config@1.0.15(dotenv@16.4.7))(ioredis@5.6.1)(pg@8.13.3)(sequelize@6.37.7(pg@8.13.3))': dependencies: '@kevisual/auth': 1.0.5 - '@kevisual/router': 0.0.9 - '@kevisual/use-config': 1.0.10(dotenv@16.4.7) - ioredis: 5.6.0 + '@kevisual/router': 0.0.13 + '@kevisual/use-config': 1.0.15(dotenv@16.4.7) + ioredis: 5.6.1 nanoid: 5.1.5 pg: 8.13.3 sequelize: 6.37.7(pg@8.13.3) @@ -1445,17 +1462,17 @@ snapshots: - supports-color - utf-8-validate - '@kevisual/load@0.0.4': + '@kevisual/load@0.0.6': dependencies: eventemitter3: 5.0.1 '@kevisual/permission@0.0.1': {} - '@kevisual/query-config@0.0.2(@kevisual/query@0.0.15(ws@8.18.0)(zod@3.24.2))': + '@kevisual/query-config@0.0.2(@kevisual/query@0.0.17(ws@8.18.0)(zod@3.24.2))': dependencies: - '@kevisual/query': 0.0.15(ws@8.18.0)(zod@3.24.2) + '@kevisual/query': 0.0.17(ws@8.18.0)(zod@3.24.2) - '@kevisual/query@0.0.15(ws@8.18.0)(zod@3.24.2)': + '@kevisual/query@0.0.17(ws@8.18.0)(zod@3.24.2)': dependencies: openai: 4.91.1(ws@8.18.0)(zod@3.24.2) transitivePeerDependencies: @@ -1463,26 +1480,22 @@ snapshots: - ws - zod - '@kevisual/router@0.0.9': + '@kevisual/router@0.0.13': dependencies: path-to-regexp: 8.2.0 selfsigned: 2.4.1 - ws: 8.18.0 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - '@kevisual/use-config@1.0.10(dotenv@16.4.7)': + '@kevisual/use-config@1.0.15(dotenv@16.4.7)': dependencies: - '@kevisual/load': 0.0.4 + '@kevisual/load': 0.0.6 dotenv: 16.4.7 '@pkgjs/parseargs@0.11.0': optional: true - '@rollup/plugin-commonjs@28.0.3(rollup@4.38.0)': + '@rollup/plugin-commonjs@28.0.3(rollup@4.40.2)': dependencies: - '@rollup/pluginutils': 5.1.2(rollup@4.38.0) + '@rollup/pluginutils': 5.1.2(rollup@4.40.2) commondir: 1.0.1 estree-walker: 2.0.2 fdir: 6.4.0(picomatch@4.0.2) @@ -1490,106 +1503,110 @@ snapshots: magic-string: 0.30.11 picomatch: 4.0.2 optionalDependencies: - rollup: 4.38.0 + rollup: 4.40.2 - '@rollup/plugin-json@6.1.0(rollup@4.38.0)': + '@rollup/plugin-json@6.1.0(rollup@4.40.2)': dependencies: - '@rollup/pluginutils': 5.1.2(rollup@4.38.0) + '@rollup/pluginutils': 5.1.2(rollup@4.40.2) optionalDependencies: - rollup: 4.38.0 + rollup: 4.40.2 - '@rollup/plugin-node-resolve@16.0.1(rollup@4.38.0)': + '@rollup/plugin-node-resolve@16.0.1(rollup@4.40.2)': dependencies: - '@rollup/pluginutils': 5.1.2(rollup@4.38.0) + '@rollup/pluginutils': 5.1.2(rollup@4.40.2) '@types/resolve': 1.20.2 deepmerge: 4.3.1 is-module: 1.0.0 resolve: 1.22.8 optionalDependencies: - rollup: 4.38.0 + rollup: 4.40.2 - '@rollup/plugin-typescript@12.1.2(rollup@4.38.0)(tslib@2.8.1)(typescript@5.8.2)': + '@rollup/plugin-typescript@12.1.2(rollup@4.40.2)(tslib@2.8.1)(typescript@5.8.3)': dependencies: - '@rollup/pluginutils': 5.1.2(rollup@4.38.0) + '@rollup/pluginutils': 5.1.2(rollup@4.40.2) resolve: 1.22.8 - typescript: 5.8.2 + typescript: 5.8.3 optionalDependencies: - rollup: 4.38.0 + rollup: 4.40.2 tslib: 2.8.1 - '@rollup/pluginutils@5.1.2(rollup@4.38.0)': + '@rollup/pluginutils@5.1.2(rollup@4.40.2)': dependencies: '@types/estree': 1.0.6 estree-walker: 2.0.2 picomatch: 4.0.2 optionalDependencies: - rollup: 4.38.0 + rollup: 4.40.2 - '@rollup/rollup-android-arm-eabi@4.38.0': + '@rollup/rollup-android-arm-eabi@4.40.2': optional: true - '@rollup/rollup-android-arm64@4.38.0': + '@rollup/rollup-android-arm64@4.40.2': optional: true - '@rollup/rollup-darwin-arm64@4.38.0': + '@rollup/rollup-darwin-arm64@4.40.2': optional: true - '@rollup/rollup-darwin-x64@4.38.0': + '@rollup/rollup-darwin-x64@4.40.2': optional: true - '@rollup/rollup-freebsd-arm64@4.38.0': + '@rollup/rollup-freebsd-arm64@4.40.2': optional: true - '@rollup/rollup-freebsd-x64@4.38.0': + '@rollup/rollup-freebsd-x64@4.40.2': optional: true - '@rollup/rollup-linux-arm-gnueabihf@4.38.0': + '@rollup/rollup-linux-arm-gnueabihf@4.40.2': optional: true - '@rollup/rollup-linux-arm-musleabihf@4.38.0': + '@rollup/rollup-linux-arm-musleabihf@4.40.2': optional: true - '@rollup/rollup-linux-arm64-gnu@4.38.0': + '@rollup/rollup-linux-arm64-gnu@4.40.2': optional: true - '@rollup/rollup-linux-arm64-musl@4.38.0': + '@rollup/rollup-linux-arm64-musl@4.40.2': optional: true - '@rollup/rollup-linux-loongarch64-gnu@4.38.0': + '@rollup/rollup-linux-loongarch64-gnu@4.40.2': optional: true - '@rollup/rollup-linux-powerpc64le-gnu@4.38.0': + '@rollup/rollup-linux-powerpc64le-gnu@4.40.2': optional: true - '@rollup/rollup-linux-riscv64-gnu@4.38.0': + '@rollup/rollup-linux-riscv64-gnu@4.40.2': optional: true - '@rollup/rollup-linux-riscv64-musl@4.38.0': + '@rollup/rollup-linux-riscv64-musl@4.40.2': optional: true - '@rollup/rollup-linux-s390x-gnu@4.38.0': + '@rollup/rollup-linux-s390x-gnu@4.40.2': optional: true - '@rollup/rollup-linux-x64-gnu@4.38.0': + '@rollup/rollup-linux-x64-gnu@4.40.2': optional: true - '@rollup/rollup-linux-x64-musl@4.38.0': + '@rollup/rollup-linux-x64-musl@4.40.2': optional: true - '@rollup/rollup-win32-arm64-msvc@4.38.0': + '@rollup/rollup-win32-arm64-msvc@4.40.2': optional: true - '@rollup/rollup-win32-ia32-msvc@4.38.0': + '@rollup/rollup-win32-ia32-msvc@4.40.2': optional: true - '@rollup/rollup-win32-x64-msvc@4.38.0': + '@rollup/rollup-win32-x64-msvc@4.40.2': optional: true '@socket.io/component-emitter@3.1.2': {} + '@types/busboy@1.5.4': + dependencies: + '@types/node': 22.15.17 + '@types/cors@2.8.17': dependencies: - '@types/node': 22.13.14 + '@types/node': 22.15.17 '@types/debug@4.1.12': dependencies: @@ -1601,7 +1618,7 @@ snapshots: '@types/http-proxy@1.17.16': dependencies: - '@types/node': 22.13.14 + '@types/node': 22.15.17 '@types/mime@1.3.5': {} @@ -1609,27 +1626,27 @@ snapshots: '@types/node-fetch@2.6.12': dependencies: - '@types/node': 22.13.14 + '@types/node': 22.15.17 form-data: 4.0.2 '@types/node-forge@1.3.11': dependencies: - '@types/node': 22.13.14 + '@types/node': 22.15.17 '@types/node@18.19.86': dependencies: undici-types: 5.26.5 - '@types/node@22.13.14': + '@types/node@22.15.17': dependencies: - undici-types: 6.20.0 + undici-types: 6.21.0 '@types/resolve@1.20.2': {} '@types/send@0.17.4': dependencies: '@types/mime': 1.3.5 - '@types/node': 22.13.14 + '@types/node': 22.15.17 '@types/validator@13.12.2': {} @@ -1731,6 +1748,10 @@ snapshots: base64-js: 1.5.1 ieee754: 1.2.1 + busboy@1.6.0: + dependencies: + streamsearch: 1.1.0 + call-bind-apply-helpers@1.0.2: dependencies: es-errors: 1.3.0 @@ -1886,7 +1907,7 @@ snapshots: engine.io@6.6.4: dependencies: '@types/cors': 2.8.17 - '@types/node': 22.13.14 + '@types/node': 22.15.17 accepts: 1.3.8 base64id: 2.0.0 cookie: 0.7.2 @@ -2049,7 +2070,7 @@ snapshots: inherits@2.0.4: {} - ioredis@5.6.0: + ioredis@5.6.1: dependencies: '@ioredis/commands': 1.2.0 cluster-key-slot: 1.1.2 @@ -2207,7 +2228,7 @@ snapshots: node-forge@1.3.1: {} - nodemon@3.1.9: + nodemon@3.1.10: dependencies: chokidar: 3.6.0 debug: 4.3.7(supports-color@5.5.0) @@ -2368,30 +2389,30 @@ snapshots: retry-as-promised@7.1.1: {} - rollup@4.38.0: + rollup@4.40.2: dependencies: '@types/estree': 1.0.7 optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.38.0 - '@rollup/rollup-android-arm64': 4.38.0 - '@rollup/rollup-darwin-arm64': 4.38.0 - '@rollup/rollup-darwin-x64': 4.38.0 - '@rollup/rollup-freebsd-arm64': 4.38.0 - '@rollup/rollup-freebsd-x64': 4.38.0 - '@rollup/rollup-linux-arm-gnueabihf': 4.38.0 - '@rollup/rollup-linux-arm-musleabihf': 4.38.0 - '@rollup/rollup-linux-arm64-gnu': 4.38.0 - '@rollup/rollup-linux-arm64-musl': 4.38.0 - '@rollup/rollup-linux-loongarch64-gnu': 4.38.0 - '@rollup/rollup-linux-powerpc64le-gnu': 4.38.0 - '@rollup/rollup-linux-riscv64-gnu': 4.38.0 - '@rollup/rollup-linux-riscv64-musl': 4.38.0 - '@rollup/rollup-linux-s390x-gnu': 4.38.0 - '@rollup/rollup-linux-x64-gnu': 4.38.0 - '@rollup/rollup-linux-x64-musl': 4.38.0 - '@rollup/rollup-win32-arm64-msvc': 4.38.0 - '@rollup/rollup-win32-ia32-msvc': 4.38.0 - '@rollup/rollup-win32-x64-msvc': 4.38.0 + '@rollup/rollup-android-arm-eabi': 4.40.2 + '@rollup/rollup-android-arm64': 4.40.2 + '@rollup/rollup-darwin-arm64': 4.40.2 + '@rollup/rollup-darwin-x64': 4.40.2 + '@rollup/rollup-freebsd-arm64': 4.40.2 + '@rollup/rollup-freebsd-x64': 4.40.2 + '@rollup/rollup-linux-arm-gnueabihf': 4.40.2 + '@rollup/rollup-linux-arm-musleabihf': 4.40.2 + '@rollup/rollup-linux-arm64-gnu': 4.40.2 + '@rollup/rollup-linux-arm64-musl': 4.40.2 + '@rollup/rollup-linux-loongarch64-gnu': 4.40.2 + '@rollup/rollup-linux-powerpc64le-gnu': 4.40.2 + '@rollup/rollup-linux-riscv64-gnu': 4.40.2 + '@rollup/rollup-linux-riscv64-musl': 4.40.2 + '@rollup/rollup-linux-s390x-gnu': 4.40.2 + '@rollup/rollup-linux-x64-gnu': 4.40.2 + '@rollup/rollup-linux-x64-musl': 4.40.2 + '@rollup/rollup-win32-arm64-msvc': 4.40.2 + '@rollup/rollup-win32-ia32-msvc': 4.40.2 + '@rollup/rollup-win32-x64-msvc': 4.40.2 fsevents: 2.3.3 rxjs@7.8.2: @@ -2527,6 +2548,8 @@ snapshots: dependencies: stream-chain: 2.2.5 + streamsearch@1.1.0: {} + streamx@2.22.0: dependencies: fast-fifo: 1.3.2 @@ -2610,13 +2633,13 @@ snapshots: tslib@2.8.1: {} - typescript@5.8.2: {} + typescript@5.8.3: {} undefsafe@2.0.5: {} undici-types@5.26.5: {} - undici-types@6.20.0: {} + undici-types@6.21.0: {} util-deprecate@1.0.2: {} @@ -2664,7 +2687,7 @@ snapshots: wkx@0.5.0: dependencies: - '@types/node': 22.13.14 + '@types/node': 22.15.17 wrap-ansi@7.0.0: dependencies: @@ -2680,7 +2703,8 @@ snapshots: ws@8.17.1: {} - ws@8.18.0: {} + ws@8.18.0: + optional: true xml2js@0.6.2: dependencies: diff --git a/src/module/index.ts b/src/module/index.ts index bb7c177..54bd429 100644 --- a/src/module/index.ts +++ b/src/module/index.ts @@ -227,7 +227,7 @@ export const handleRequest = async (req: http.IncomingMessage, res: http.ServerR res.write(msg || 'Not Found App\n'); res.end(); }; - if (app === 'ai' || user === 'resources') { + if (app === 'ai' || app === 'resources') { return aiProxy(req, res, { createNotFoundPage, }); diff --git a/src/module/proxy/ai-proxy.ts b/src/module/proxy/ai-proxy.ts index 125e8bb..54ce0b3 100644 --- a/src/module/proxy/ai-proxy.ts +++ b/src/module/proxy/ai-proxy.ts @@ -4,8 +4,10 @@ import { filterKeys } from './http-proxy.ts'; import { getUserFromRequest } from '@/utils/get-user.ts'; import { UserPermission, Permission } from '@kevisual/permission'; import { getLoginUser } from '@/middleware/auth.ts'; +import busboy from 'busboy'; +import { getContentType } from '../get-content-type.ts'; -export const aiProxy = async ( +const getAiProxy = async ( req: IncomingMessage, res: ServerResponse, opts: { @@ -21,13 +23,13 @@ export const aiProxy = async ( let objectName = ''; let owner = ''; const { user, app } = getUserFromRequest(req); - if (user === 'ai') { + if (app === 'ai') { const version = params.get('version') || '1.0.0'; // root/ai objectName = pathname.replace(`/${user}/${app}/`, `${user}/${app}/${version}/`); owner = user; } else { - objectName = pathname.replace(`/${user}`, ``); // resources/root/ - owner = app; + objectName = pathname.replace(`/${user}/${app}/`, `${user}/`); // resources/root/ + owner = user; } try { const stat = await minioClient.statObject(bucketName, objectName); @@ -70,3 +72,77 @@ export const aiProxy = async ( return false; } }; +export const getMetadata = (pathname: string) => { + let meta: any = { 'app-source': 'user-app' }; + const isHtml = pathname.endsWith('.html'); + if (isHtml) { + meta = { + ...meta, + 'Content-Type': 'text/html; charset=utf-8', + 'Cache-Control': 'no-cache', + }; + } else { + meta = { + ...meta, + 'Content-Type': getContentType(pathname), + 'Cache-Control': 'max-age=31536000, immutable', + }; + } + return meta; +}; +export const postProxy = async (req: IncomingMessage, res: ServerResponse, opts: { createNotFoundPage: (msg?: string) => any }) => { + const _u = new URL(req.url, 'http://localhost'); + + const pathname = _u.pathname; + const params = _u.searchParams; + let objectName = ''; + let owner = ''; + const { user, app } = getUserFromRequest(req); + if (app === 'ai') { + const version = params.get('version') || '1.0.0'; // root/ai + objectName = pathname.replace(`/${user}/${app}/`, `${user}/${app}/${version}/`); + owner = user; + } else { + objectName = pathname.replace(`/${user}/${app}/`, `${user}/`); // resources/root/ + owner = user; + } + const loginUser = await getLoginUser(req); + if (loginUser?.tokenUser?.username !== owner) { + return opts?.createNotFoundPage?.('no permission'); + } + const bb = busboy({ headers: req.headers }); + bb.on('file', async (name, file, info) => { + try { + await minioClient.putObject(bucketName, objectName, file, undefined, { + ...getMetadata(pathname), + }); + end({ success: true, name, info }, '上传成功', 200); + } catch (error) { + end({ error: error }, '上传失败', 500); + } + }); + const end = (data: any, message?: string, code = 200) => { + res.writeHead(code, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ code: code, data: data, message: message || 'success' })); + }; + bb.on('finish', end); + bb.on('error', (err) => { + console.error('Busboy 错误:', err); + end({ error: err }, '文件解析失败', 500); + }); + + req.pipe(bb); +}; +export const aiProxy = async ( + req: IncomingMessage, + res: ServerResponse, + opts: { + createNotFoundPage: (msg?: string) => any; + }, +) => { + if (req.method === 'POST') { + return postProxy(req, res, opts); + } + + return getAiProxy(req, res, opts); +};