From 7b0b00feffbc4a47aff519a68a29aaf45cba5676 Mon Sep 17 00:00:00 2001 From: abearxiong Date: Sat, 17 Jan 2026 23:11:08 +0800 Subject: [PATCH] test --- bun.config.mjs | 2 +- package.json | 12 +- pnpm-lock.yaml | 209 +++++++---------------- src/auth/models/user-secret.ts | 1 - src/modules/auth.ts | 42 ++--- src/modules/fm-manager/proxy/ai-proxy.ts | 2 +- src/route.ts | 7 +- src/routes/app-manager/list.ts | 2 + wxmsg/src/modules/config.ts | 2 +- 9 files changed, 95 insertions(+), 184 deletions(-) diff --git a/bun.config.mjs b/bun.config.mjs index 071d6b4..8bbab0b 100644 --- a/bun.config.mjs +++ b/bun.config.mjs @@ -4,7 +4,7 @@ import { execSync } from 'node:child_process'; const entry = 'src/index.ts'; const naming = 'app'; -const external = ['sequelize', 'pg', 'sqlite3', 'ioredis', 'pm2', 'bun']; +const external = ['sequelize', 'pg', 'sqlite3', 'ioredis', 'pm2', 'bun', '@kevisual/router']; /** * @type {import('bun').BuildConfig} */ diff --git a/package.json b/package.json index 7a60449..ae0c48b 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "drizzle-orm": "^0.45.1", "drizzle-zod": "^0.8.3", "eventemitter3": "^5.0.1", - "ioredis": "^5.9.1", + "ioredis": "^5.9.2", "minio": "^8.0.6", "pg": "^8.17.1", "pm2": "^6.0.14", @@ -76,7 +76,7 @@ "@kevisual/logger": "^0.0.4", "@kevisual/oss": "0.0.16", "@kevisual/permission": "^0.0.3", - "@kevisual/router": "0.0.53", + "@kevisual/router": "0.0.55", "@kevisual/types": "^0.0.11", "@kevisual/use-config": "^1.0.28", "@types/archiver": "^7.0.0", @@ -84,16 +84,16 @@ "@types/crypto-js": "^4.2.2", "@types/jsonwebtoken": "^9.0.10", "@types/lodash-es": "^4.17.12", - "@types/node": "^25.0.8", + "@types/node": "^25.0.9", "@types/semver": "^7.7.1", "@types/xml2js": "^0.4.14", "archiver": "^7.0.1", - "better-sqlite3": "^12.6.0", + "better-sqlite3": "^12.6.2", "crypto-js": "^4.2.0", "dayjs": "^1.11.19", "dotenv": "^17.2.3", - "es-toolkit": "^1.43.0", - "ioredis": "^5.9.1", + "es-toolkit": "^1.44.0", + "ioredis": "^5.9.2", "jsonwebtoken": "^9.0.3", "lodash-es": "^4.17.22", "minio": "^8.0.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4f0259d..0ab175e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,9 +30,6 @@ importers: bullmq: specifier: ^5.66.5 version: 5.66.5 - bun: - specifier: ^1.3.6 - version: 1.3.6 busboy: specifier: ^1.6.0 version: 1.6.0 @@ -44,16 +41,16 @@ importers: version: 0.31.8 drizzle-orm: specifier: ^0.45.1 - version: 0.45.1(better-sqlite3@12.6.0)(bun-types@1.3.6)(pg@8.17.1) + version: 0.45.1(better-sqlite3@12.6.2)(bun-types@1.3.6)(pg@8.17.1) drizzle-zod: specifier: ^0.8.3 - version: 0.8.3(drizzle-orm@0.45.1(better-sqlite3@12.6.0)(bun-types@1.3.6)(pg@8.17.1))(zod@4.3.5) + version: 0.8.3(drizzle-orm@0.45.1(better-sqlite3@12.6.2)(bun-types@1.3.6)(pg@8.17.1))(zod@4.3.5) eventemitter3: specifier: ^5.0.1 version: 5.0.1 ioredis: - specifier: ^5.9.1 - version: 5.9.1 + specifier: ^5.9.2 + version: 5.9.2 minio: specifier: ^8.0.6 version: 8.0.6 @@ -101,8 +98,8 @@ importers: specifier: ^0.0.3 version: 0.0.3 '@kevisual/router': - specifier: 0.0.53 - version: 0.0.53 + specifier: 0.0.55 + version: 0.0.55 '@kevisual/types': specifier: ^0.0.11 version: 0.0.11 @@ -125,8 +122,8 @@ importers: specifier: ^4.17.12 version: 4.17.12 '@types/node': - specifier: ^25.0.8 - version: 25.0.8 + specifier: ^25.0.9 + version: 25.0.9 '@types/semver': specifier: ^7.7.1 version: 7.7.1 @@ -137,8 +134,8 @@ importers: specifier: ^7.0.1 version: 7.0.1 better-sqlite3: - specifier: ^12.6.0 - version: 12.6.0 + specifier: ^12.6.2 + version: 12.6.2 crypto-js: specifier: ^4.2.0 version: 4.2.0 @@ -149,8 +146,8 @@ importers: specifier: ^17.2.3 version: 17.2.3 es-toolkit: - specifier: ^1.43.0 - version: 1.43.0 + specifier: ^1.44.0 + version: 1.44.0 jsonwebtoken: specifier: ^9.0.3 version: 9.0.3 @@ -560,8 +557,8 @@ packages: '@kevisual/router@0.0.50': resolution: {integrity: sha512-g9Rpf4QoowJdEdSnHD/f998fYDQ2ILYEnEkyAKw9Cj2RLVIWxMdMaHn4BRTUXXEJ35nYsPaj2LWVQap3OH2/hQ==} - '@kevisual/router@0.0.53': - resolution: {integrity: sha512-Bw9xYVWyxRhd230nF1ac7cyvzWDYKI/3V+Fr1Ew1Bfr0Ey8KuWb1MgPPopHkRHCCcUcysLtWXfu/JRiTAoBmGA==} + '@kevisual/router@0.0.55': + resolution: {integrity: sha512-DVhXbbUCfSWWXsp1id1HBrkGiMZ6nFUBD1/C5E7IpLE5B32w7sv2xjKUt98OriFl0uyuneMEIZuZsAQaKplQ5g==} '@kevisual/types@0.0.11': resolution: {integrity: sha512-idNLDTEKVdNXZHFQq8PTN62nflh94kvGtx+v8YDcMxt0Zo+HWVZTFElm+dMQxAs/vn4wo8F2r3VwzWNX/vcqwQ==} @@ -613,61 +610,6 @@ packages: resolution: {integrity: sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==} engines: {node: ^14.21.3 || >=16} - '@oven/bun-darwin-aarch64@1.3.6': - resolution: {integrity: sha512-27rypIapNkYboOSylkf1tD9UW9Ado2I+P1NBL46Qz29KmOjTL6WuJ7mHDC5O66CYxlOkF5r93NPDAC3lFHYBXw==} - cpu: [arm64] - os: [darwin] - - '@oven/bun-darwin-x64-baseline@1.3.6': - resolution: {integrity: sha512-nqtr+pTsHqusYpG2OZc6s+AmpWDB/FmBvstrK0y5zkti4OqnCuu7Ev2xNjS7uyb47NrAFF40pWqkpaio5XEd7w==} - cpu: [x64] - os: [darwin] - - '@oven/bun-darwin-x64@1.3.6': - resolution: {integrity: sha512-I82xGzPkBxzBKgbl8DsA0RfMQCWTWjNmLjIEkW1ECiv3qK02kHGQ5FGUr/29L/SuvnGsULW4tBTRNZiMzL37nA==} - cpu: [x64] - os: [darwin] - - '@oven/bun-linux-aarch64-musl@1.3.6': - resolution: {integrity: sha512-FR+iJt17rfFgYgpxL3M67AUwujOgjw52ZJzB9vElI5jQXNjTyOKf8eH4meSk4vjlYF3h/AjKYd6pmN0OIUlVKQ==} - cpu: [arm64] - os: [linux] - - '@oven/bun-linux-aarch64@1.3.6': - resolution: {integrity: sha512-YaQEAYjBanoOOtpqk/c5GGcfZIyxIIkQ2m1TbHjedRmJNwxzWBhGinSARFkrRIc3F8pRIGAopXKvJ/2rjN1LzQ==} - cpu: [arm64] - os: [linux] - - '@oven/bun-linux-x64-baseline@1.3.6': - resolution: {integrity: sha512-jRmnX18ak8WzqLrex3siw0PoVKyIeI5AiCv4wJLgSs7VKfOqrPycfHIWfIX2jdn7ngqbHFPzI09VBKANZ4Pckg==} - cpu: [x64] - os: [linux] - - '@oven/bun-linux-x64-musl-baseline@1.3.6': - resolution: {integrity: sha512-7FjVnxnRTp/AgWqSQRT/Vt9TYmvnZ+4M+d9QOKh/Lf++wIFXFGSeAgD6bV1X/yr2UPVmZDk+xdhr2XkU7l2v3w==} - cpu: [x64] - os: [linux] - - '@oven/bun-linux-x64-musl@1.3.6': - resolution: {integrity: sha512-YeXcJ9K6vJAt1zSkeA21J6pTe7PgDMLTHKGI3nQBiMYnYf7Ob3K+b/ChSCznrJG7No5PCPiQPg4zTgA+BOTmSA==} - cpu: [x64] - os: [linux] - - '@oven/bun-linux-x64@1.3.6': - resolution: {integrity: sha512-egfngj0dfJ868cf30E7B+ye9KUWSebYxOG4l9YP5eWeMXCtenpenx0zdKtAn9qxJgEJym5AN6trtlk+J6x8Lig==} - cpu: [x64] - os: [linux] - - '@oven/bun-windows-x64-baseline@1.3.6': - resolution: {integrity: sha512-PFUa7JL4lGoyyppeS4zqfuoXXih+gSE0XxhDMrCPVEUev0yhGNd/tbWBvcdpYnUth80owENoGjc8s5Knopv9wA==} - cpu: [x64] - os: [win32] - - '@oven/bun-windows-x64@1.3.6': - resolution: {integrity: sha512-Sr1KwUcbB0SEpnSPO22tNJppku2khjFluEst+mTGhxHzAGQTQncNeJxDnt3F15n+p9Q+mlcorxehd68n1siikQ==} - cpu: [x64] - os: [win32] - '@paralleldrive/cuid2@2.2.2': resolution: {integrity: sha512-ZOBkgDwEdoYVlSeRbYYXs0S9MejQofiVYoTbKzy/6GQa39/q5tQU2IX46+shYnUkpEl3wc+J6wRlar7r2EK2xA==} @@ -773,8 +715,8 @@ packages: '@types/node@25.0.3': resolution: {integrity: sha512-W609buLVRVmeW693xKfzHeIV6nJGGz98uCPfeXI1ELMLXVeKYZ9m15fAMSaUPBHYLGFsVRcMmSCksQOrZV9BYA==} - '@types/node@25.0.8': - resolution: {integrity: sha512-powIePYMmC3ibL0UJ2i2s0WIbq6cg6UyVFQxSCpaPxxzAaziRfimGivjdF943sSGV6RADVbk0Nvlm5P/FB44Zg==} + '@types/node@25.0.9': + resolution: {integrity: sha512-/rpCXHlCWeqClNBwUhDcusJxXYDjZTyE8v5oTO7WbL8eij2nKhUeU89/6xgjU7N4/Vh3He0BtyhJdQbDyhiXAw==} '@types/readdir-glob@1.1.5': resolution: {integrity: sha512-raiuEPUYqXu+nvtY2Pe8s8FEmZ3x5yAH4VkLdihcPdalvsHltomrRC9BzuStrJ9yk06470hS0Crw0f1pXqD+Hg==} @@ -895,8 +837,8 @@ packages: resolution: {integrity: sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg==} engines: {node: '>=10.0.0'} - better-sqlite3@12.6.0: - resolution: {integrity: sha512-FXI191x+D6UPWSze5IzZjhz+i9MK9nsuHsmTX9bXVl52k06AfZ2xql0lrgIUuzsMsJ7Vgl5kIptvDgBLIV3ZSQ==} + better-sqlite3@12.6.2: + resolution: {integrity: sha512-8VYKM3MjCa9WcaSAI3hzwhmyHVlH8tiGFwf0RlTsZPWJ1I5MkzjiudCo4KC4DxOaL/53A5B1sI/IbldNFDbsKA==} engines: {node: 20.x || 22.x || 23.x || 24.x || 25.x} binary-extensions@2.3.0: @@ -950,12 +892,6 @@ packages: bun-types@1.3.6: resolution: {integrity: sha512-OlFwHcnNV99r//9v5IIOgQ9Uk37gZqrNMCcqEaExdkVq3Avwqok1bJFmvGMCkCE0FqzdY8VMOZpfpR3lwI+CsQ==} - bun@1.3.6: - resolution: {integrity: sha512-Tn98GlZVN2WM7+lg/uGn5DzUao37Yc0PUz7yzYHdeF5hd+SmHQGbCUIKE4Sspdgtxn49LunK3mDNBC2Qn6GJjw==} - cpu: [arm64, x64] - os: [darwin, linux, win32] - hasBin: true - busboy@1.6.0: resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} engines: {node: '>=10.16.0'} @@ -1286,8 +1222,8 @@ packages: resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==} engines: {node: '>= 0.4'} - es-toolkit@1.43.0: - resolution: {integrity: sha512-SKCT8AsWvYzBBuUqMk4NPwFlSdqLpJwmy6AP322ERn8W2YLIB6JBXnwMI2Qsh2gfphT3q7EKAxKb23cvFHFwKA==} + es-toolkit@1.44.0: + resolution: {integrity: sha512-6penXeZalaV88MM3cGkFZZfOoLGWshWWfdy0tWw/RlVVyhvMaWSBTOvXNeiW3e5FwdS5ePW0LGEu17zT139ktg==} esbuild-register@3.6.0: resolution: {integrity: sha512-H2/S7Pm8a9CL1uhp9OvjwrBh5Pvx0H8qVOxNu8Wed9Y7qv56MPtq+GGM8RJpq6glYJn9Wspr8uw7l55uyinNeg==} @@ -1522,6 +1458,10 @@ packages: resolution: {integrity: sha512-BXNqFQ66oOsR82g9ajFFsR8ZKrjVvYCLyeML9IvSMAsP56XH2VXBdZjmI11p65nXXJxTEt1hie3J2QeFJVgrtQ==} engines: {node: '>=12.22.0'} + ioredis@5.9.2: + resolution: {integrity: sha512-tAAg/72/VxOUW7RQSX1pIxJVucYKcjFjfvj60L57jrZpYCHC3XN0WCQ3sNYL4Gmvv+7GPvTAjc+KSdeNuE8oWQ==} + engines: {node: '>=12.22.0'} + ip-address@9.0.5: resolution: {integrity: sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==} engines: {node: '>= 12'} @@ -2596,7 +2536,7 @@ snapshots: '@kevisual/auth': 1.0.5 '@kevisual/router': 0.0.21 '@kevisual/use-config': 1.0.28(dotenv@17.2.3) - ioredis: 5.9.1 + ioredis: 5.9.2 nanoid: 5.1.6 pg: 8.17.1 sequelize: 6.37.7(pg@8.17.1) @@ -2622,7 +2562,7 @@ snapshots: '@kevisual/auth': 1.0.5 '@kevisual/router': 0.0.23 '@kevisual/use-config': 1.0.28(dotenv@17.2.3) - ioredis: 5.9.1 + ioredis: 5.9.2 nanoid: 5.1.6 pg: 8.17.1 sequelize: 6.37.7(pg@8.17.1) @@ -2719,7 +2659,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@kevisual/router@0.0.53': {} + '@kevisual/router@0.0.55': {} '@kevisual/types@0.0.11': {} @@ -2752,39 +2692,6 @@ snapshots: '@noble/hashes@1.8.0': {} - '@oven/bun-darwin-aarch64@1.3.6': - optional: true - - '@oven/bun-darwin-x64-baseline@1.3.6': - optional: true - - '@oven/bun-darwin-x64@1.3.6': - optional: true - - '@oven/bun-linux-aarch64-musl@1.3.6': - optional: true - - '@oven/bun-linux-aarch64@1.3.6': - optional: true - - '@oven/bun-linux-x64-baseline@1.3.6': - optional: true - - '@oven/bun-linux-x64-musl-baseline@1.3.6': - optional: true - - '@oven/bun-linux-x64-musl@1.3.6': - optional: true - - '@oven/bun-linux-x64@1.3.6': - optional: true - - '@oven/bun-windows-x64-baseline@1.3.6': - optional: true - - '@oven/bun-windows-x64@1.3.6': - optional: true - '@paralleldrive/cuid2@2.2.2': dependencies: '@noble/hashes': 1.8.0 @@ -2948,13 +2855,13 @@ snapshots: '@types/busboy@1.5.4': dependencies: - '@types/node': 25.0.8 + '@types/node': 25.0.9 '@types/cookie@0.4.1': {} '@types/cors@2.8.17': dependencies: - '@types/node': 25.0.8 + '@types/node': 25.0.9 '@types/crypto-js@4.2.2': {} @@ -2965,7 +2872,7 @@ snapshots: '@types/jsonwebtoken@9.0.10': dependencies: '@types/ms': 0.7.34 - '@types/node': 25.0.8 + '@types/node': 25.0.9 '@types/lodash-es@4.17.12': dependencies: @@ -2977,31 +2884,31 @@ snapshots: '@types/node-forge@1.3.11': dependencies: - '@types/node': 25.0.8 + '@types/node': 25.0.9 '@types/node@25.0.3': dependencies: undici-types: 7.16.0 - '@types/node@25.0.8': + '@types/node@25.0.9': dependencies: undici-types: 7.16.0 '@types/readdir-glob@1.1.5': dependencies: - '@types/node': 25.0.8 + '@types/node': 25.0.9 '@types/semver@7.7.1': {} '@types/send@1.2.1': dependencies: - '@types/node': 25.0.8 + '@types/node': 25.0.9 '@types/validator@13.12.2': {} '@types/ws@8.18.1': dependencies: - '@types/node': 25.0.8 + '@types/node': 25.0.9 '@types/xml2js@0.4.14': dependencies: @@ -3107,7 +3014,7 @@ snapshots: basic-ftp@5.0.5: {} - better-sqlite3@12.6.0: + better-sqlite3@12.6.2: dependencies: bindings: 1.5.0 prebuild-install: 7.1.3 @@ -3175,21 +3082,7 @@ snapshots: bun-types@1.3.6: dependencies: - '@types/node': 25.0.8 - - bun@1.3.6: - optionalDependencies: - '@oven/bun-darwin-aarch64': 1.3.6 - '@oven/bun-darwin-x64': 1.3.6 - '@oven/bun-darwin-x64-baseline': 1.3.6 - '@oven/bun-linux-aarch64': 1.3.6 - '@oven/bun-linux-aarch64-musl': 1.3.6 - '@oven/bun-linux-x64': 1.3.6 - '@oven/bun-linux-x64-baseline': 1.3.6 - '@oven/bun-linux-x64-musl': 1.3.6 - '@oven/bun-linux-x64-musl-baseline': 1.3.6 - '@oven/bun-windows-x64': 1.3.6 - '@oven/bun-windows-x64-baseline': 1.3.6 + '@types/node': 25.0.9 busboy@1.6.0: dependencies: @@ -3356,15 +3249,15 @@ snapshots: transitivePeerDependencies: - supports-color - drizzle-orm@0.45.1(better-sqlite3@12.6.0)(bun-types@1.3.6)(pg@8.17.1): + drizzle-orm@0.45.1(better-sqlite3@12.6.2)(bun-types@1.3.6)(pg@8.17.1): optionalDependencies: - better-sqlite3: 12.6.0 + better-sqlite3: 12.6.2 bun-types: 1.3.6 pg: 8.17.1 - drizzle-zod@0.8.3(drizzle-orm@0.45.1(better-sqlite3@12.6.0)(bun-types@1.3.6)(pg@8.17.1))(zod@4.3.5): + drizzle-zod@0.8.3(drizzle-orm@0.45.1(better-sqlite3@12.6.2)(bun-types@1.3.6)(pg@8.17.1))(zod@4.3.5): dependencies: - drizzle-orm: 0.45.1(better-sqlite3@12.6.0)(bun-types@1.3.6)(pg@8.17.1) + drizzle-orm: 0.45.1(better-sqlite3@12.6.2)(bun-types@1.3.6)(pg@8.17.1) zod: 4.3.5 eastasianwidth@0.2.0: {} @@ -3391,7 +3284,7 @@ snapshots: dependencies: '@types/cookie': 0.4.1 '@types/cors': 2.8.17 - '@types/node': 25.0.8 + '@types/node': 25.0.9 accepts: 1.3.8 base64id: 2.0.0 cookie: 0.4.2 @@ -3414,7 +3307,7 @@ snapshots: es-errors@1.3.0: {} - es-toolkit@1.43.0: {} + es-toolkit@1.44.0: {} esbuild-register@3.6.0(esbuild@0.25.12): dependencies: @@ -3685,6 +3578,20 @@ snapshots: transitivePeerDependencies: - supports-color + ioredis@5.9.2: + dependencies: + '@ioredis/commands': 1.5.0 + cluster-key-slot: 1.1.2 + debug: 4.4.3(supports-color@5.5.0) + denque: 2.1.0 + lodash.defaults: 4.2.0 + lodash.isarguments: 3.1.0 + redis-errors: 1.2.0 + redis-parser: 3.0.0 + standard-as-callback: 2.1.0 + transitivePeerDependencies: + - supports-color + ip-address@9.0.5: dependencies: jsbn: 1.1.0 @@ -4605,7 +4512,7 @@ snapshots: wkx@0.5.0: dependencies: - '@types/node': 25.0.8 + '@types/node': 25.0.9 wrap-ansi@7.0.0: dependencies: diff --git a/src/auth/models/user-secret.ts b/src/auth/models/user-secret.ts index 1e7e35c..739a9e3 100644 --- a/src/auth/models/user-secret.ts +++ b/src/auth/models/user-secret.ts @@ -54,7 +54,6 @@ export class UserSecret extends Model { } const secretToken = await oauth.verifyToken(token); if (secretToken) { - console.log('verifyToken: verified as normal token'); return secretToken; } console.log('verifyToken: try to verify as secret key'); diff --git a/src/modules/auth.ts b/src/modules/auth.ts index bdc3c5e..f9baf61 100644 --- a/src/modules/auth.ts +++ b/src/modules/auth.ts @@ -20,27 +20,27 @@ export const getTokenFromRequest = (req: http.IncomingMessage) => { } return token; } -export const checkAuth = async (req: http.IncomingMessage, res: http.ServerResponse) => { - const token = getTokenFromRequest(req); - const resNoPermission = () => { - res.statusCode = 401; - res.end(error('Invalid authorization')); - return { tokenUser: null, token: null }; - }; - if (!token) { - return resNoPermission(); - } - let tokenUser; - try { - tokenUser = await User.verifyToken(token); - } catch (e) { - console.log('checkAuth error', e); - res.statusCode = 401; - res.end(error('Invalid token')); - return { tokenUser: null, token: null }; - } - return { tokenUser, token }; -}; +// export const checkAuth = async (req: http.IncomingMessage, res: http.ServerResponse) => { +// const token = getTokenFromRequest(req); +// const resNoPermission = () => { +// res.statusCode = 401; +// res.end(error('Invalid authorization')); +// return { tokenUser: null, token: null }; +// }; +// if (!token) { +// return resNoPermission(); +// } +// let tokenUser; +// try { +// tokenUser = await User.verifyToken(token); +// } catch (e) { +// console.log('checkAuth error', e); +// res.statusCode = 401; +// res.end(error('Invalid token')); +// return { tokenUser: null, token: null }; +// } +// return { tokenUser, token }; +// }; export const getLoginUserByToken = async (token: string) => { if (token) { diff --git a/src/modules/fm-manager/proxy/ai-proxy.ts b/src/modules/fm-manager/proxy/ai-proxy.ts index 8e40a53..f144def 100644 --- a/src/modules/fm-manager/proxy/ai-proxy.ts +++ b/src/modules/fm-manager/proxy/ai-proxy.ts @@ -7,7 +7,7 @@ import { getLoginUser } from '@/modules/auth.ts'; import busboy from 'busboy'; import { getContentType, getTextContentType } from '../get-content-type.ts'; import { OssBase } from '@kevisual/oss'; -import { parseSearchValue } from '@kevisual/router/browser'; +import { parseSearchValue } from '@kevisual/router/src/server/parse-body.ts'; import { logger } from '@/modules/logger.ts'; import { pipeBusboy } from '../pipe-busboy.ts'; import { pipeMinioStream } from '../pipe.ts'; diff --git a/src/route.ts b/src/route.ts index 003a667..6de1a81 100644 --- a/src/route.ts +++ b/src/route.ts @@ -26,12 +26,15 @@ export const addAuth = (app: App) => { return; } if (!token) { - app.throw(401, 'Token is required'); + ctx.throw(401, 'Token is required'); } const user = await User.getOauthUser(token); + console.log('auth user: exists', !user); if (!user) { - app.throw(401, 'Token is invalid'); + ctx.throw(401, 'Token is invalid'); + return; } + console.log(`auth user: ${user.username} (${user.id})`); const someInfo = getSomeInfoFromReq(ctx); if (someInfo.isBrowser && !ctx.req?.cookies?.['token']) { createCookie({ accessToken: token }, ctx); diff --git a/src/routes/app-manager/list.ts b/src/routes/app-manager/list.ts index ca9ae68..670df92 100644 --- a/src/routes/app-manager/list.ts +++ b/src/routes/app-manager/list.ts @@ -40,6 +40,7 @@ app description: '获取应用详情,可以通过id,或者key+version来获取', }) .define(async (ctx) => { + console.log('get app manager called'); const tokenUser = ctx.state.tokenUser; const id = ctx.query.id; const { key, version } = ctx.query?.data || {}; @@ -61,6 +62,7 @@ app if (!am) { throw new CustomError('app not found'); } + console.log('get app', am.id, am.key, am.version); ctx.body = prefixFix(am, tokenUser.username); }) .addTo(app); diff --git a/wxmsg/src/modules/config.ts b/wxmsg/src/modules/config.ts index 072577e..1ab4737 100644 --- a/wxmsg/src/modules/config.ts +++ b/wxmsg/src/modules/config.ts @@ -10,4 +10,4 @@ import { useConfig } from '@kevisual/use-config'; export const config = useConfig() -console.log('配置项:', config); \ No newline at end of file +// console.log('配置项:', config); \ No newline at end of file