diff --git a/.gitignore b/.gitignore index b908d9b..58768e5 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,8 @@ release/* .turbo -.env +.env* +!.env.example pack-dist app.config.json5.envision diff --git a/app.config.json5.example b/app.config.json5.example deleted file mode 100644 index 371afe1..0000000 --- a/app.config.json5.example +++ /dev/null @@ -1,23 +0,0 @@ -{ - port: 4005, // 端口 - tokenSecret: '', - appPath: 'apps', - appName: 'codeflow', - domain: '*', - mainApp: 'https://kevisual.xiongxiao.me', - postgres: { - username: 'root', - host: 'localhost', - database: 'postgres', - password: '*****', - port: 5432, - }, - redis: {}, - minio: { - endPoint: 'minio.xiongxiao.me', - bucketName: 'resources', - useSSL: false, - accessKey: 'username', - secretKey: 'password', - }, -} diff --git a/package.json b/package.json index e639489..f442ea8 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "start": "pm2 start dist/app.mjs --name codecenter", "release": "node ./config/release/index.mjs", "pub": "envision pack -p -u", - "ssh": "ssh -L 6379:localhost:6379 light ", + "ssh": "ssh -L 6379:localhost:6379 -L 5432:localhost:5432 light ", "ssh:sky": "ssh -L 6379:172.21.32.13:6379 sky", "dev:lib": "turbo run dev:lib", "build:lib": "turbo run build", @@ -38,13 +38,14 @@ ], "license": "UNLICENSED", "dependencies": { - "@kevisual/local-app-manager": "0.1.9", + "@kevisual/local-app-manager": "0.1.10", "@kevisual/router": "0.0.9", "@kevisual/use-config": "^1.0.10", "@types/semver": "^7.5.8", "archiver": "^7.0.1", "crypto-js": "^4.2.0", "dayjs": "^1.11.13", + "dotenv": "^16.4.7", "formidable": "^3.5.2", "ioredis": "^5.6.0", "json5": "^2.2.3", @@ -67,8 +68,8 @@ }, "devDependencies": { "@kevisual/code-center-module": "workspace:*", - "@kevisual/permission": "workspace:*", "@kevisual/oss": "workspace:*", + "@kevisual/permission": "workspace:*", "@kevisual/types": "^0.0.6", "@rollup/plugin-alias": "^5.1.1", "@rollup/plugin-commonjs": "^28.0.3", @@ -81,14 +82,14 @@ "@types/formidable": "^3.4.5", "@types/jsonwebtoken": "^9.0.9", "@types/lodash-es": "^4.17.12", - "@types/node": "^22.13.11", + "@types/node": "^22.13.13", "@types/react": "^19.0.12", "@types/uuid": "^10.0.0", "concurrently": "^9.1.2", "cross-env": "^7.0.3", "nodemon": "^3.1.9", "rimraf": "^6.0.1", - "rollup": "^4.36.0", + "rollup": "^4.37.0", "rollup-plugin-copy": "^3.5.0", "rollup-plugin-dts": "^6.2.1", "tape": "^5.9.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9c5f4d6..e5043bb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,8 +14,8 @@ importers: .: dependencies: '@kevisual/local-app-manager': - specifier: 0.1.9 - version: 0.1.9(@kevisual/router@0.0.9)(@kevisual/types@0.0.6)(@kevisual/use-config@1.0.10(dotenv@16.4.7))(pm2@6.0.5) + specifier: 0.1.10 + version: 0.1.10(@kevisual/router@0.0.9)(@kevisual/types@0.0.6)(@kevisual/use-config@1.0.10(dotenv@16.4.7))(pm2@6.0.5) '@kevisual/router': specifier: 0.0.9 version: 0.0.9 @@ -34,6 +34,9 @@ importers: dayjs: specifier: ^1.11.13 version: 1.11.13 + dotenv: + specifier: ^16.4.7 + version: 16.4.7 formidable: specifier: ^3.5.2 version: 3.5.2 @@ -69,7 +72,7 @@ importers: version: 6.0.5 rollup-plugin-esbuild: specifier: ^6.2.1 - version: 6.2.1(esbuild@0.25.0)(rollup@4.36.0) + version: 6.2.1(esbuild@0.25.0)(rollup@4.37.0) semver: specifier: ^7.7.1 version: 7.7.1 @@ -106,22 +109,22 @@ importers: version: 0.0.6 '@rollup/plugin-alias': specifier: ^5.1.1 - version: 5.1.1(rollup@4.36.0) + version: 5.1.1(rollup@4.37.0) '@rollup/plugin-commonjs': specifier: ^28.0.3 - version: 28.0.3(rollup@4.36.0) + version: 28.0.3(rollup@4.37.0) '@rollup/plugin-json': specifier: ^6.1.0 - version: 6.1.0(rollup@4.36.0) + version: 6.1.0(rollup@4.37.0) '@rollup/plugin-node-resolve': specifier: ^16.0.1 - version: 16.0.1(rollup@4.36.0) + version: 16.0.1(rollup@4.37.0) '@rollup/plugin-replace': specifier: ^6.0.2 - version: 6.0.2(rollup@4.36.0) + version: 6.0.2(rollup@4.37.0) '@rollup/plugin-typescript': specifier: ^12.1.2 - version: 12.1.2(rollup@4.36.0)(tslib@2.8.1)(typescript@5.8.2) + version: 12.1.2(rollup@4.37.0)(tslib@2.8.1)(typescript@5.8.2) '@types/archiver': specifier: ^6.0.3 version: 6.0.3 @@ -138,8 +141,8 @@ importers: specifier: ^4.17.12 version: 4.17.12 '@types/node': - specifier: ^22.13.11 - version: 22.13.11 + specifier: ^22.13.13 + version: 22.13.13 '@types/react': specifier: ^19.0.12 version: 19.0.12 @@ -159,14 +162,14 @@ importers: specifier: latest version: 6.0.1 rollup: - specifier: ^4.36.0 - version: 4.36.0 + specifier: ^4.37.0 + version: 4.37.0 rollup-plugin-copy: specifier: ^3.5.0 version: 3.5.0 rollup-plugin-dts: specifier: ^6.2.1 - version: 6.2.1(rollup@4.36.0)(typescript@5.8.2) + version: 6.2.1(rollup@4.37.0)(typescript@5.8.2) tape: specifier: ^5.9.0 version: 5.9.0 @@ -302,16 +305,10 @@ importers: version: 8.4.0(tsx@4.19.3)(typescript@5.8.2) submodules/pay-center-code: - devDependencies: - '@kevisual/router': - specifier: 0.0.10-beta.1 - version: 0.0.10-beta.1 - '@kevisual/use-config': - specifier: ^1.0.10 - version: 1.0.10(dotenv@16.4.7) - tsup: - specifier: ^8.4.0 - version: 8.4.0(tsx@4.19.3)(typescript@5.8.2) + dependencies: + dotenv: + specifier: ^16.4.7 + version: 16.4.7 submodules/permission: devDependencies: @@ -514,17 +511,14 @@ packages: '@kevisual/load@0.0.4': resolution: {integrity: sha512-TJBieKsEoEPfP4+tDyhNZdMX2LMAGiDZ/IrAXPFWB4jeFP0Ywm1W5xDV52LhhHq4nwTmuhyTVmPxJYiEVYTHtA==} - '@kevisual/local-app-manager@0.1.9': - resolution: {integrity: sha512-oppYUjvpPg/7gBw1h3dX63fhxB8MvGc74yGgIM4JifvSuOYLcZ9oZyauYV+5lQVh2tjJImOuUmRHnVXu1FWKDQ==} + '@kevisual/local-app-manager@0.1.10': + resolution: {integrity: sha512-4zE3ndsGe5eA0Wl8b8JgWIbulX8uH8vZWuvBkgnAP9ry99XFYHx5Z3XGO990ZKqzRMy3jIFlfooAc1x1iMoZvQ==} peerDependencies: - '@kevisual/router': ^0.0.6-alpha-2 + '@kevisual/router': ^0.0.6 '@kevisual/types': ^0.0.1 '@kevisual/use-config': ^1.0.5 pm2: ^5.4.3 - '@kevisual/router@0.0.10-beta.1': - resolution: {integrity: sha512-jl3f6HMdEd0B/6y14w437NatvpOKQ7Gkkr9vFNXvJ3tnYk7ozwjtavLSP3k4MWr5Er9SCT0KBX7+FjnvslCsSw==} - '@kevisual/router@0.0.9': resolution: {integrity: sha512-qPyC2GVJ7iOIdJCCKNDsWMAKOQeSJW9HBpL5ZWKHTbi+t4jJBGTzIlXmjKeMHRd0lr/Qq1imQvlkSh4hlrbodA==} @@ -646,96 +640,196 @@ packages: cpu: [arm] os: [android] + '@rollup/rollup-android-arm-eabi@4.37.0': + resolution: {integrity: sha512-l7StVw6WAa8l3vA1ov80jyetOAEo1FtHvZDbzXDO/02Sq/QVvqlHkYoFwDJPIMj0GKiistsBudfx5tGFnwYWDQ==} + cpu: [arm] + os: [android] + '@rollup/rollup-android-arm64@4.36.0': resolution: {integrity: sha512-NyfuLvdPdNUfUNeYKUwPwKsE5SXa2J6bCt2LdB/N+AxShnkpiczi3tcLJrm5mA+eqpy0HmaIY9F6XCa32N5yzg==} cpu: [arm64] os: [android] + '@rollup/rollup-android-arm64@4.37.0': + resolution: {integrity: sha512-6U3SlVyMxezt8Y+/iEBcbp945uZjJwjZimu76xoG7tO1av9VO691z8PkhzQ85ith2I8R2RddEPeSfcbyPfD4hA==} + cpu: [arm64] + os: [android] + '@rollup/rollup-darwin-arm64@4.36.0': resolution: {integrity: sha512-JQ1Jk5G4bGrD4pWJQzWsD8I1n1mgPXq33+/vP4sk8j/z/C2siRuxZtaUA7yMTf71TCZTZl/4e1bfzwUmFb3+rw==} cpu: [arm64] os: [darwin] + '@rollup/rollup-darwin-arm64@4.37.0': + resolution: {integrity: sha512-+iTQ5YHuGmPt10NTzEyMPbayiNTcOZDWsbxZYR1ZnmLnZxG17ivrPSWFO9j6GalY0+gV3Jtwrrs12DBscxnlYA==} + cpu: [arm64] + os: [darwin] + '@rollup/rollup-darwin-x64@4.36.0': resolution: {integrity: sha512-6c6wMZa1lrtiRsbDziCmjE53YbTkxMYhhnWnSW8R/yqsM7a6mSJ3uAVT0t8Y/DGt7gxUWYuFM4bwWk9XCJrFKA==} cpu: [x64] os: [darwin] + '@rollup/rollup-darwin-x64@4.37.0': + resolution: {integrity: sha512-m8W2UbxLDcmRKVjgl5J/k4B8d7qX2EcJve3Sut7YGrQoPtCIQGPH5AMzuFvYRWZi0FVS0zEY4c8uttPfX6bwYQ==} + cpu: [x64] + os: [darwin] + '@rollup/rollup-freebsd-arm64@4.36.0': resolution: {integrity: sha512-KXVsijKeJXOl8QzXTsA+sHVDsFOmMCdBRgFmBb+mfEb/7geR7+C8ypAml4fquUt14ZyVXaw2o1FWhqAfOvA4sg==} cpu: [arm64] os: [freebsd] + '@rollup/rollup-freebsd-arm64@4.37.0': + resolution: {integrity: sha512-FOMXGmH15OmtQWEt174v9P1JqqhlgYge/bUjIbiVD1nI1NeJ30HYT9SJlZMqdo1uQFyt9cz748F1BHghWaDnVA==} + cpu: [arm64] + os: [freebsd] + '@rollup/rollup-freebsd-x64@4.36.0': resolution: {integrity: sha512-dVeWq1ebbvByI+ndz4IJcD4a09RJgRYmLccwlQ8bPd4olz3Y213uf1iwvc7ZaxNn2ab7bjc08PrtBgMu6nb4pQ==} cpu: [x64] os: [freebsd] + '@rollup/rollup-freebsd-x64@4.37.0': + resolution: {integrity: sha512-SZMxNttjPKvV14Hjck5t70xS3l63sbVwl98g3FlVVx2YIDmfUIy29jQrsw06ewEYQ8lQSuY9mpAPlmgRD2iSsA==} + cpu: [x64] + os: [freebsd] + '@rollup/rollup-linux-arm-gnueabihf@4.36.0': resolution: {integrity: sha512-bvXVU42mOVcF4le6XSjscdXjqx8okv4n5vmwgzcmtvFdifQ5U4dXFYaCB87namDRKlUL9ybVtLQ9ztnawaSzvg==} cpu: [arm] os: [linux] + '@rollup/rollup-linux-arm-gnueabihf@4.37.0': + resolution: {integrity: sha512-hhAALKJPidCwZcj+g+iN+38SIOkhK2a9bqtJR+EtyxrKKSt1ynCBeqrQy31z0oWU6thRZzdx53hVgEbRkuI19w==} + cpu: [arm] + os: [linux] + '@rollup/rollup-linux-arm-musleabihf@4.36.0': resolution: {integrity: sha512-JFIQrDJYrxOnyDQGYkqnNBtjDwTgbasdbUiQvcU8JmGDfValfH1lNpng+4FWlhaVIR4KPkeddYjsVVbmJYvDcg==} cpu: [arm] os: [linux] + '@rollup/rollup-linux-arm-musleabihf@4.37.0': + resolution: {integrity: sha512-jUb/kmn/Gd8epbHKEqkRAxq5c2EwRt0DqhSGWjPFxLeFvldFdHQs/n8lQ9x85oAeVb6bHcS8irhTJX2FCOd8Ag==} + cpu: [arm] + os: [linux] + '@rollup/rollup-linux-arm64-gnu@4.36.0': resolution: {integrity: sha512-KqjYVh3oM1bj//5X7k79PSCZ6CvaVzb7Qs7VMWS+SlWB5M8p3FqufLP9VNp4CazJ0CsPDLwVD9r3vX7Ci4J56A==} cpu: [arm64] os: [linux] + '@rollup/rollup-linux-arm64-gnu@4.37.0': + resolution: {integrity: sha512-oNrJxcQT9IcbcmKlkF+Yz2tmOxZgG9D9GRq+1OE6XCQwCVwxixYAa38Z8qqPzQvzt1FCfmrHX03E0pWoXm1DqA==} + cpu: [arm64] + os: [linux] + '@rollup/rollup-linux-arm64-musl@4.36.0': resolution: {integrity: sha512-QiGnhScND+mAAtfHqeT+cB1S9yFnNQ/EwCg5yE3MzoaZZnIV0RV9O5alJAoJKX/sBONVKeZdMfO8QSaWEygMhw==} cpu: [arm64] os: [linux] + '@rollup/rollup-linux-arm64-musl@4.37.0': + resolution: {integrity: sha512-pfxLBMls+28Ey2enpX3JvjEjaJMBX5XlPCZNGxj4kdJyHduPBXtxYeb8alo0a7bqOoWZW2uKynhHxF/MWoHaGQ==} + cpu: [arm64] + os: [linux] + '@rollup/rollup-linux-loongarch64-gnu@4.36.0': resolution: {integrity: sha512-1ZPyEDWF8phd4FQtTzMh8FQwqzvIjLsl6/84gzUxnMNFBtExBtpL51H67mV9xipuxl1AEAerRBgBwFNpkw8+Lg==} cpu: [loong64] os: [linux] + '@rollup/rollup-linux-loongarch64-gnu@4.37.0': + resolution: {integrity: sha512-yCE0NnutTC/7IGUq/PUHmoeZbIwq3KRh02e9SfFh7Vmc1Z7atuJRYWhRME5fKgT8aS20mwi1RyChA23qSyRGpA==} + cpu: [loong64] + os: [linux] + '@rollup/rollup-linux-powerpc64le-gnu@4.36.0': resolution: {integrity: sha512-VMPMEIUpPFKpPI9GZMhJrtu8rxnp6mJR3ZzQPykq4xc2GmdHj3Q4cA+7avMyegXy4n1v+Qynr9fR88BmyO74tg==} cpu: [ppc64] os: [linux] + '@rollup/rollup-linux-powerpc64le-gnu@4.37.0': + resolution: {integrity: sha512-NxcICptHk06E2Lh3a4Pu+2PEdZ6ahNHuK7o6Np9zcWkrBMuv21j10SQDJW3C9Yf/A/P7cutWoC/DptNLVsZ0VQ==} + cpu: [ppc64] + os: [linux] + '@rollup/rollup-linux-riscv64-gnu@4.36.0': resolution: {integrity: sha512-ttE6ayb/kHwNRJGYLpuAvB7SMtOeQnVXEIpMtAvx3kepFQeowVED0n1K9nAdraHUPJ5hydEMxBpIR7o4nrm8uA==} cpu: [riscv64] os: [linux] + '@rollup/rollup-linux-riscv64-gnu@4.37.0': + resolution: {integrity: sha512-PpWwHMPCVpFZLTfLq7EWJWvrmEuLdGn1GMYcm5MV7PaRgwCEYJAwiN94uBuZev0/J/hFIIJCsYw4nLmXA9J7Pw==} + cpu: [riscv64] + os: [linux] + + '@rollup/rollup-linux-riscv64-musl@4.37.0': + resolution: {integrity: sha512-DTNwl6a3CfhGTAOYZ4KtYbdS8b+275LSLqJVJIrPa5/JuIufWWZ/QFvkxp52gpmguN95eujrM68ZG+zVxa8zHA==} + cpu: [riscv64] + os: [linux] + '@rollup/rollup-linux-s390x-gnu@4.36.0': resolution: {integrity: sha512-4a5gf2jpS0AIe7uBjxDeUMNcFmaRTbNv7NxI5xOCs4lhzsVyGR/0qBXduPnoWf6dGC365saTiwag8hP1imTgag==} cpu: [s390x] os: [linux] + '@rollup/rollup-linux-s390x-gnu@4.37.0': + resolution: {integrity: sha512-hZDDU5fgWvDdHFuExN1gBOhCuzo/8TMpidfOR+1cPZJflcEzXdCy1LjnklQdW8/Et9sryOPJAKAQRw8Jq7Tg+A==} + cpu: [s390x] + os: [linux] + '@rollup/rollup-linux-x64-gnu@4.36.0': resolution: {integrity: sha512-5KtoW8UWmwFKQ96aQL3LlRXX16IMwyzMq/jSSVIIyAANiE1doaQsx/KRyhAvpHlPjPiSU/AYX/8m+lQ9VToxFQ==} cpu: [x64] os: [linux] + '@rollup/rollup-linux-x64-gnu@4.37.0': + resolution: {integrity: sha512-pKivGpgJM5g8dwj0ywBwe/HeVAUSuVVJhUTa/URXjxvoyTT/AxsLTAbkHkDHG7qQxLoW2s3apEIl26uUe08LVQ==} + cpu: [x64] + os: [linux] + '@rollup/rollup-linux-x64-musl@4.36.0': resolution: {integrity: sha512-sycrYZPrv2ag4OCvaN5js+f01eoZ2U+RmT5as8vhxiFz+kxwlHrsxOwKPSA8WyS+Wc6Epid9QeI/IkQ9NkgYyQ==} cpu: [x64] os: [linux] + '@rollup/rollup-linux-x64-musl@4.37.0': + resolution: {integrity: sha512-E2lPrLKE8sQbY/2bEkVTGDEk4/49UYRVWgj90MY8yPjpnGBQ+Xi1Qnr7b7UIWw1NOggdFQFOLZ8+5CzCiz143w==} + cpu: [x64] + os: [linux] + '@rollup/rollup-win32-arm64-msvc@4.36.0': resolution: {integrity: sha512-qbqt4N7tokFwwSVlWDsjfoHgviS3n/vZ8LK0h1uLG9TYIRuUTJC88E1xb3LM2iqZ/WTqNQjYrtmtGmrmmawB6A==} cpu: [arm64] os: [win32] + '@rollup/rollup-win32-arm64-msvc@4.37.0': + resolution: {integrity: sha512-Jm7biMazjNzTU4PrQtr7VS8ibeys9Pn29/1bm4ph7CP2kf21950LgN+BaE2mJ1QujnvOc6p54eWWiVvn05SOBg==} + cpu: [arm64] + os: [win32] + '@rollup/rollup-win32-ia32-msvc@4.36.0': resolution: {integrity: sha512-t+RY0JuRamIocMuQcfwYSOkmdX9dtkr1PbhKW42AMvaDQa+jOdpUYysroTF/nuPpAaQMWp7ye+ndlmmthieJrQ==} cpu: [ia32] os: [win32] + '@rollup/rollup-win32-ia32-msvc@4.37.0': + resolution: {integrity: sha512-e3/1SFm1OjefWICB2Ucstg2dxYDkDTZGDYgwufcbsxTHyqQps1UQf33dFEChBNmeSsTOyrjw2JJq0zbG5GF6RA==} + cpu: [ia32] + os: [win32] + '@rollup/rollup-win32-x64-msvc@4.36.0': resolution: {integrity: sha512-aRXd7tRZkWLqGbChgcMMDEHjOKudo1kChb1Jt1IfR8cY/KIpgNviLeJy5FUb9IpSuQj8dU2fAYNMPW/hLKOSTw==} cpu: [x64] os: [win32] + '@rollup/rollup-win32-x64-msvc@4.37.0': + resolution: {integrity: sha512-LWbXUBwn/bcLx2sSsqy7pK5o+Nr+VCoRoAohfJ5C/aBio9nfJmGQqHAhU6pwxV/RmyTk5AqdySma7uwWGlmeuA==} + cpu: [x64] + os: [win32] + '@socket.io/component-emitter@3.1.2': resolution: {integrity: sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==} @@ -790,6 +884,9 @@ packages: '@types/node@22.13.11': resolution: {integrity: sha512-iEUCUJoU0i3VnrCmgoWCXttklWcvoCIx4jzcP22fioIVSdTmjgoEvmAO/QPw6TcS9k5FrNgn4w7q5lGOd1CT5g==} + '@types/node@22.13.13': + resolution: {integrity: sha512-ClsL5nMwKaBRwPcCvH8E7+nU4GxHVx1axNvMZTFHMEfNI7oahimt26P5zjVCRrjiIWj6YFXfE1v3dEp94wLcGQ==} + '@types/react@19.0.12': resolution: {integrity: sha512-V6Ar115dBDrjbtXSrS+/Oruobc+qVbbUxDFC1RSbRqLt5SYvxxyIDrSC85RWml54g+jfNeEMZhEj7wW07ONQhA==} @@ -2232,6 +2329,11 @@ packages: engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true + rollup@4.37.0: + resolution: {integrity: sha512-iAtQy/L4QFU+rTJ1YUjXqJOJzuwEghqWzCEYD2FEghT7Gsy1VdABntrO4CLopA5IkflTyqNiLNwPcOJ3S7UKLg==} + engines: {node: '>=18.0.0', npm: '>=8.0.0'} + hasBin: true + run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} @@ -2754,18 +2856,6 @@ packages: utf-8-validate: optional: true - ws@8.18.1: - resolution: {integrity: sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w==} - engines: {node: '>=10.0.0'} - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: '>=5.0.2' - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - xml2js@0.5.0: resolution: {integrity: sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==} engines: {node: '>=4.0.0'} @@ -2929,22 +3019,13 @@ snapshots: dependencies: eventemitter3: 5.0.1 - '@kevisual/local-app-manager@0.1.9(@kevisual/router@0.0.9)(@kevisual/types@0.0.6)(@kevisual/use-config@1.0.10(dotenv@16.4.7))(pm2@6.0.5)': + '@kevisual/local-app-manager@0.1.10(@kevisual/router@0.0.9)(@kevisual/types@0.0.6)(@kevisual/use-config@1.0.10(dotenv@16.4.7))(pm2@6.0.5)': dependencies: '@kevisual/router': 0.0.9 '@kevisual/types': 0.0.6 '@kevisual/use-config': 1.0.10(dotenv@16.4.7) pm2: 6.0.5 - '@kevisual/router@0.0.10-beta.1': - dependencies: - path-to-regexp: 8.2.0 - selfsigned: 2.4.1 - ws: 8.18.1 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - '@kevisual/router@0.0.9': dependencies: path-to-regexp: 8.2.0 @@ -3039,6 +3120,10 @@ snapshots: optionalDependencies: rollup: 4.36.0 + '@rollup/plugin-alias@5.1.1(rollup@4.37.0)': + optionalDependencies: + rollup: 4.37.0 + '@rollup/plugin-commonjs@28.0.3(rollup@4.36.0)': dependencies: '@rollup/pluginutils': 5.1.2(rollup@4.36.0) @@ -3051,12 +3136,30 @@ snapshots: optionalDependencies: rollup: 4.36.0 + '@rollup/plugin-commonjs@28.0.3(rollup@4.37.0)': + dependencies: + '@rollup/pluginutils': 5.1.2(rollup@4.37.0) + commondir: 1.0.1 + estree-walker: 2.0.2 + fdir: 6.3.0(picomatch@4.0.2) + is-reference: 1.2.1 + magic-string: 0.30.11 + picomatch: 4.0.2 + optionalDependencies: + rollup: 4.37.0 + '@rollup/plugin-json@6.1.0(rollup@4.36.0)': dependencies: '@rollup/pluginutils': 5.1.2(rollup@4.36.0) optionalDependencies: rollup: 4.36.0 + '@rollup/plugin-json@6.1.0(rollup@4.37.0)': + dependencies: + '@rollup/pluginutils': 5.1.2(rollup@4.37.0) + optionalDependencies: + rollup: 4.37.0 + '@rollup/plugin-node-resolve@16.0.1(rollup@4.36.0)': dependencies: '@rollup/pluginutils': 5.1.2(rollup@4.36.0) @@ -3067,6 +3170,16 @@ snapshots: optionalDependencies: rollup: 4.36.0 + '@rollup/plugin-node-resolve@16.0.1(rollup@4.37.0)': + dependencies: + '@rollup/pluginutils': 5.1.2(rollup@4.37.0) + '@types/resolve': 1.20.2 + deepmerge: 4.3.1 + is-module: 1.0.0 + resolve: 1.22.8 + optionalDependencies: + rollup: 4.37.0 + '@rollup/plugin-replace@6.0.2(rollup@4.36.0)': dependencies: '@rollup/pluginutils': 5.1.2(rollup@4.36.0) @@ -3074,6 +3187,13 @@ snapshots: optionalDependencies: rollup: 4.36.0 + '@rollup/plugin-replace@6.0.2(rollup@4.37.0)': + dependencies: + '@rollup/pluginutils': 5.1.2(rollup@4.37.0) + magic-string: 0.30.11 + optionalDependencies: + rollup: 4.37.0 + '@rollup/plugin-typescript@12.1.2(rollup@4.36.0)(tslib@2.8.1)(typescript@5.8.2)': dependencies: '@rollup/pluginutils': 5.1.2(rollup@4.36.0) @@ -3083,6 +3203,15 @@ snapshots: rollup: 4.36.0 tslib: 2.8.1 + '@rollup/plugin-typescript@12.1.2(rollup@4.37.0)(tslib@2.8.1)(typescript@5.8.2)': + dependencies: + '@rollup/pluginutils': 5.1.2(rollup@4.37.0) + resolve: 1.22.8 + typescript: 5.8.2 + optionalDependencies: + rollup: 4.37.0 + tslib: 2.8.1 + '@rollup/pluginutils@5.1.2(rollup@4.36.0)': dependencies: '@types/estree': 1.0.6 @@ -3091,63 +3220,131 @@ snapshots: optionalDependencies: rollup: 4.36.0 + '@rollup/pluginutils@5.1.2(rollup@4.37.0)': + dependencies: + '@types/estree': 1.0.6 + estree-walker: 2.0.2 + picomatch: 4.0.2 + optionalDependencies: + rollup: 4.37.0 + '@rollup/rollup-android-arm-eabi@4.36.0': optional: true + '@rollup/rollup-android-arm-eabi@4.37.0': + optional: true + '@rollup/rollup-android-arm64@4.36.0': optional: true + '@rollup/rollup-android-arm64@4.37.0': + optional: true + '@rollup/rollup-darwin-arm64@4.36.0': optional: true + '@rollup/rollup-darwin-arm64@4.37.0': + optional: true + '@rollup/rollup-darwin-x64@4.36.0': optional: true + '@rollup/rollup-darwin-x64@4.37.0': + optional: true + '@rollup/rollup-freebsd-arm64@4.36.0': optional: true + '@rollup/rollup-freebsd-arm64@4.37.0': + optional: true + '@rollup/rollup-freebsd-x64@4.36.0': optional: true + '@rollup/rollup-freebsd-x64@4.37.0': + optional: true + '@rollup/rollup-linux-arm-gnueabihf@4.36.0': optional: true + '@rollup/rollup-linux-arm-gnueabihf@4.37.0': + optional: true + '@rollup/rollup-linux-arm-musleabihf@4.36.0': optional: true + '@rollup/rollup-linux-arm-musleabihf@4.37.0': + optional: true + '@rollup/rollup-linux-arm64-gnu@4.36.0': optional: true + '@rollup/rollup-linux-arm64-gnu@4.37.0': + optional: true + '@rollup/rollup-linux-arm64-musl@4.36.0': optional: true + '@rollup/rollup-linux-arm64-musl@4.37.0': + optional: true + '@rollup/rollup-linux-loongarch64-gnu@4.36.0': optional: true + '@rollup/rollup-linux-loongarch64-gnu@4.37.0': + optional: true + '@rollup/rollup-linux-powerpc64le-gnu@4.36.0': optional: true + '@rollup/rollup-linux-powerpc64le-gnu@4.37.0': + optional: true + '@rollup/rollup-linux-riscv64-gnu@4.36.0': optional: true + '@rollup/rollup-linux-riscv64-gnu@4.37.0': + optional: true + + '@rollup/rollup-linux-riscv64-musl@4.37.0': + optional: true + '@rollup/rollup-linux-s390x-gnu@4.36.0': optional: true + '@rollup/rollup-linux-s390x-gnu@4.37.0': + optional: true + '@rollup/rollup-linux-x64-gnu@4.36.0': optional: true + '@rollup/rollup-linux-x64-gnu@4.37.0': + optional: true + '@rollup/rollup-linux-x64-musl@4.36.0': optional: true + '@rollup/rollup-linux-x64-musl@4.37.0': + optional: true + '@rollup/rollup-win32-arm64-msvc@4.36.0': optional: true + '@rollup/rollup-win32-arm64-msvc@4.37.0': + optional: true + '@rollup/rollup-win32-ia32-msvc@4.36.0': optional: true + '@rollup/rollup-win32-ia32-msvc@4.37.0': + optional: true + '@rollup/rollup-win32-x64-msvc@4.36.0': optional: true + '@rollup/rollup-win32-x64-msvc@4.37.0': + optional: true + '@socket.io/component-emitter@3.1.2': {} '@tootallnate/quickjs-emscripten@0.23.0': {} @@ -3160,7 +3357,7 @@ snapshots: '@types/cors@2.8.17': dependencies: - '@types/node': 22.13.11 + '@types/node': 22.13.13 '@types/crypto-js@4.2.2': {} @@ -3172,21 +3369,21 @@ snapshots: '@types/formidable@3.4.5': dependencies: - '@types/node': 22.13.11 + '@types/node': 22.13.13 '@types/fs-extra@8.1.5': dependencies: - '@types/node': 22.13.11 + '@types/node': 22.13.13 '@types/glob@7.2.0': dependencies: '@types/minimatch': 5.1.2 - '@types/node': 22.13.11 + '@types/node': 22.13.13 '@types/jsonwebtoken@9.0.9': dependencies: '@types/ms': 0.7.34 - '@types/node': 22.13.11 + '@types/node': 22.13.13 '@types/lodash-es@4.17.12': dependencies: @@ -3200,19 +3397,23 @@ snapshots: '@types/node-forge@1.3.11': dependencies: - '@types/node': 22.13.11 + '@types/node': 22.13.13 '@types/node@22.13.11': dependencies: undici-types: 6.20.0 + '@types/node@22.13.13': + dependencies: + undici-types: 6.20.0 + '@types/react@19.0.12': dependencies: csstype: 3.1.3 '@types/readdir-glob@1.1.5': dependencies: - '@types/node': 22.13.11 + '@types/node': 22.13.13 '@types/resolve@1.20.2': {} @@ -3625,7 +3826,7 @@ snapshots: dependencies: '@types/cookie': 0.4.1 '@types/cors': 2.8.17 - '@types/node': 22.13.11 + '@types/node': 22.13.13 accepts: 1.3.8 base64id: 2.0.0 cookie: 0.4.2 @@ -4775,6 +4976,14 @@ snapshots: optionalDependencies: '@babel/code-frame': 7.26.2 + rollup-plugin-dts@6.2.1(rollup@4.37.0)(typescript@5.8.2): + dependencies: + magic-string: 0.30.17 + rollup: 4.37.0 + typescript: 5.8.2 + optionalDependencies: + '@babel/code-frame': 7.26.2 + rollup-plugin-esbuild@6.2.1(esbuild@0.25.0)(rollup@4.36.0): dependencies: debug: 4.4.0 @@ -4786,6 +4995,17 @@ snapshots: transitivePeerDependencies: - supports-color + rollup-plugin-esbuild@6.2.1(esbuild@0.25.0)(rollup@4.37.0): + dependencies: + debug: 4.4.0 + es-module-lexer: 1.6.0 + esbuild: 0.25.0 + get-tsconfig: 4.10.0 + rollup: 4.37.0 + unplugin-utils: 0.2.4 + transitivePeerDependencies: + - supports-color + rollup@4.36.0: dependencies: '@types/estree': 1.0.6 @@ -4811,6 +5031,32 @@ snapshots: '@rollup/rollup-win32-x64-msvc': 4.36.0 fsevents: 2.3.3 + rollup@4.37.0: + dependencies: + '@types/estree': 1.0.6 + optionalDependencies: + '@rollup/rollup-android-arm-eabi': 4.37.0 + '@rollup/rollup-android-arm64': 4.37.0 + '@rollup/rollup-darwin-arm64': 4.37.0 + '@rollup/rollup-darwin-x64': 4.37.0 + '@rollup/rollup-freebsd-arm64': 4.37.0 + '@rollup/rollup-freebsd-x64': 4.37.0 + '@rollup/rollup-linux-arm-gnueabihf': 4.37.0 + '@rollup/rollup-linux-arm-musleabihf': 4.37.0 + '@rollup/rollup-linux-arm64-gnu': 4.37.0 + '@rollup/rollup-linux-arm64-musl': 4.37.0 + '@rollup/rollup-linux-loongarch64-gnu': 4.37.0 + '@rollup/rollup-linux-powerpc64le-gnu': 4.37.0 + '@rollup/rollup-linux-riscv64-gnu': 4.37.0 + '@rollup/rollup-linux-riscv64-musl': 4.37.0 + '@rollup/rollup-linux-s390x-gnu': 4.37.0 + '@rollup/rollup-linux-x64-gnu': 4.37.0 + '@rollup/rollup-linux-x64-musl': 4.37.0 + '@rollup/rollup-win32-arm64-msvc': 4.37.0 + '@rollup/rollup-win32-ia32-msvc': 4.37.0 + '@rollup/rollup-win32-x64-msvc': 4.37.0 + fsevents: 2.3.3 + run-parallel@1.2.0: dependencies: queue-microtask: 1.2.3 @@ -5178,7 +5424,7 @@ snapshots: picocolors: 1.1.1 postcss-load-config: 6.0.1(tsx@4.19.3) resolve-from: 5.0.0 - rollup: 4.36.0 + rollup: 4.37.0 source-map: 0.8.0-beta.0 sucrase: 3.35.0 tinyexec: 0.3.2 @@ -5357,7 +5603,7 @@ snapshots: wkx@0.5.0: dependencies: - '@types/node': 22.13.11 + '@types/node': 22.13.13 wrap-ansi@7.0.0: dependencies: @@ -5379,8 +5625,6 @@ snapshots: ws@8.18.0: {} - ws@8.18.1: {} - xml2js@0.5.0: dependencies: sax: 1.4.1 diff --git a/src/app.ts b/src/app.ts index 9a75c89..f78ea03 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,12 +1,10 @@ import { App } from '@kevisual/router'; -import { useConfig } from '@kevisual/use-config'; import * as redisLib from './modules/redis.ts'; import * as minioLib from './modules/minio.ts'; import * as sequelizeLib from './modules/sequelize.ts'; import { useContextKey, useContext } from '@kevisual/use-config/context'; import { SimpleRouter } from '@kevisual/router/simple'; import { OssBase } from '@kevisual/oss/services'; -useConfig(); export const router = useContextKey('router', () => new SimpleRouter()); export const oss = useContextKey( 'oss', diff --git a/src/index.ts b/src/index.ts index 1c1f37a..4853da4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,13 +1,11 @@ -import { useConfig } from '@kevisual/use-config'; +import { config } from './modules/config.ts'; import { app } from './app.ts'; import './route.ts'; -const config = useConfig(); import { uploadMiddleware } from './routes-simple/upload.ts'; +import { port } from './modules/config.ts'; // if (import.meta.url === `file://${process.argv[1]}`) { -app.listen(config.port, () => { - console.log(`server is running at http://localhost:${config.port}`); +app.listen(port, () => { + console.log(`server is running at http://localhost:${port}`); }); app.server.on(uploadMiddleware); - -console.log(`run ${config.appName} done`); diff --git a/src/models/user.ts b/src/models/user.ts index bdc3b6c..b327f4d 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -1,292 +1,3 @@ -// import { useConfig } from '@kevisual/use-config'; -// import { DataTypes, Model, Op, Sequelize } from 'sequelize'; -// import { createToken, checkToken } from '@kevisual/auth'; -// import { cryptPwd } from '@kevisual/auth'; -// import { customRandom, nanoid, customAlphabet } from 'nanoid'; -// import { CustomError } from '@kevisual/router'; -// import { Org } from './org.ts'; - -// import { useContextKey } from '@kevisual/use-config/context'; -// import { Redis } from 'ioredis'; -// export const redis = useContextKey('redis'); -// const sequelize = useContextKey('sequelize'); -// const config = useConfig<{ tokenSecret: string }>(); - -// type UserData = { -// orgs?: string[]; -// }; -// export class User extends Model { -// declare id: string; -// declare username: string; -// declare nickname: string; // 昵称 -// declare alias: string; // 别名 -// declare password: string; -// declare salt: string; -// declare needChangePassword: boolean; -// declare description: string; -// declare data: UserData; -// declare type: string; // user | org | visitor -// declare owner: string; -// declare orgId: string; -// declare email: string; -// declare avatar: string; -// tokenUser: any; -// setTokenUser(tokenUser: any) { -// this.tokenUser = tokenUser; -// } -// /** -// * uid 是用于 orgId 的用户id 真实用户的id -// * @param uid -// * @returns -// */ -// async createToken(uid?: string, loginType?: 'default' | 'plugin' | 'month' | 'season' | 'year') { -// const { id, username, type } = this; -// let expireTime = 60 * 60 * 24 * 7; // 7 days -// switch (loginType) { -// case 'plugin': -// expireTime = 60 * 60 * 24 * 30 * 12; // 365 days -// break; -// case 'month': -// expireTime = 60 * 60 * 24 * 30; // 30 days -// break; -// case 'season': -// expireTime = 60 * 60 * 24 * 30 * 3; // 90 days -// break; -// case 'year': -// expireTime = 60 * 60 * 24 * 30 * 12; // 365 days -// break; -// } -// const now = new Date().getTime(); -// const token = await createToken({ id, username, uid, type }, config.tokenSecret); -// return { token, expireTime: now + expireTime }; -// } -// static async verifyToken(token: string) { -// const ct = await checkToken(token, config.tokenSecret); -// const tokenUser = ct.payload; -// return tokenUser; -// } -// static async createUser(username: string, password?: string, description?: string) { -// const user = await User.findOne({ where: { username } }); -// if (user) { -// throw new CustomError('User already exists'); -// } -// const salt = nanoid(6); -// let needChangePassword = !password; -// password = password || '123456'; -// const cPassword = cryptPwd(password, salt); -// return await User.create({ username, password: cPassword, description, salt, needChangePassword }); -// } -// static async createOrg(username: string, owner: string, description?: string) { -// const user = await User.findOne({ where: { username } }); -// if (user) { -// throw new CustomError('User already exists'); -// } -// const me = await User.findByPk(owner); -// if (!me) { -// throw new CustomError('Owner not found'); -// } -// if (me.type !== 'user') { -// throw new CustomError('Owner type is not user'); -// } -// const org = await Org.create({ username, description, users: [{ uid: owner, role: 'owner' }] }); -// const newUser = await User.create({ username, password: '', description, type: 'org', owner, orgId: org.id }); -// // owner add -// await redis.del(`user:${me.id}:orgs`); -// return newUser; -// } -// createPassword(password: string) { -// const salt = this.salt; -// const cPassword = cryptPwd(password, salt); -// this.password = cPassword; -// return cPassword; -// } -// checkPassword(password: string) { -// const salt = this.salt; -// const cPassword = cryptPwd(password, salt); -// return this.password === cPassword; -// } -// async getInfo() { -// const orgs = await this.getOrgs(); -// return { -// id: this.id, -// username: this.username, -// nickname: this.nickname, -// description: this.description, -// needChangePassword: this.needChangePassword, -// type: this.type, -// avatar: this.avatar, -// orgs, -// }; -// } -// async getOrgs() { -// let id = this.id; -// if (this.type === 'org') { -// if (this.tokenUser && this.tokenUser.uid) { -// id = this.tokenUser.uid; -// } else { -// console.log('getOrgs', 'no uid', this.id, this.username); -// throw new CustomError('Permission denied'); -// } -// } -// const cache = await redis.get(`user:${id}:orgs`); -// if (cache) { -// return JSON.parse(cache) as string[]; -// } -// const orgs = await Org.findAll({ -// order: [['updatedAt', 'DESC']], -// where: { -// users: { -// [Op.contains]: [ -// { -// uid: id, -// }, -// ], -// }, -// }, -// }); -// const orgNames = orgs.map((org) => org.username); -// if (orgNames.length > 0) { -// await redis.set(`user:${id}:orgs`, JSON.stringify(orgNames), 'EX', 60 * 60); // 1 hour -// } -// return orgNames; -// } -// async expireOrgs() { -// await redis.del(`user:${this.id}:orgs`); -// } -// } -// User.init( -// { -// id: { -// type: DataTypes.UUID, -// primaryKey: true, -// defaultValue: DataTypes.UUIDV4, -// }, -// username: { -// type: DataTypes.STRING, -// allowNull: false, -// unique: true, -// // 用户名或者手机号 -// // 创建后避免修改的字段,当注册用户后,用户名注册则默认不能用手机号 -// }, -// nickname: { -// type: DataTypes.TEXT, -// allowNull: true, -// }, -// alias: { -// type: DataTypes.TEXT, -// allowNull: true, // 别名,网络请求的别名,需要唯一,不能和username重复 -// defaultValue: '', -// }, -// password: { -// type: DataTypes.STRING, -// allowNull: true, -// }, -// email: { -// type: DataTypes.STRING, -// allowNull: true, -// }, -// avatar: { -// type: DataTypes.TEXT, -// allowNull: true, -// }, -// salt: { -// type: DataTypes.STRING, -// allowNull: true, -// }, -// description: { -// type: DataTypes.TEXT, -// }, -// type: { -// type: DataTypes.STRING, -// defaultValue: 'user', -// }, -// owner: { -// type: DataTypes.UUID, -// }, -// orgId: { -// type: DataTypes.UUID, -// }, -// needChangePassword: { -// type: DataTypes.BOOLEAN, -// defaultValue: false, -// }, -// data: { -// type: DataTypes.JSONB, -// defaultValue: {}, -// }, -// }, -// { -// sequelize, -// tableName: 'cf_user', // codeflow user -// paranoid: true, -// }, -// ); -// User.sync({ alter: true, logging: false }) -// .then((res) => { -// initializeUser(); -// }) -// .catch((err) => { -// console.error('Sync User error', err); -// }); - -// const letter = 'abcdefghijklmnopqrstuvwxyz'; -// const custom = customAlphabet(letter, 6); -// export const initializeUser = async (pwd = custom()) => { -// const w = await User.findOne({ where: { username: 'root' }, logging: false }); -// if (!w) { -// const root = await User.createUser('root', pwd, '系统管理员'); -// const org = await User.createOrg('admin', root.id, '管理员'); -// console.info(' new Users name', root.username, org.username); -// console.info('new Users root password', pwd); -// console.info('new Users id', root.id, org.id); -// const demo = await createDemoUser(); -// return { -// code: 200, -// data: { root, org, pwd: pwd, demo }, -// }; -// } else { -// return { -// code: 500, -// message: 'Users has been created', -// }; -// } -// }; -// export const createDemoUser = async (username = 'demo', pwd = custom()) => { -// const u = await User.findOne({ where: { username }, logging: false }); -// if (!u) { -// const user = await User.createUser(username, pwd, 'demo'); -// console.info('new Users name', user.username, pwd); -// return { -// code: 200, -// data: { user, pwd: pwd }, -// }; -// } else { -// console.info('Users has been created', u.username); -// return { -// code: 500, -// message: 'Users has been created', -// }; -// } -// }; -// // initializeUser(); - -// export class UserServices extends User { -// static async loginByPhone(phone: string) { -// let user = await User.findOne({ where: { username: phone } }); -// let isNew = false; -// if (!user) { -// user = await User.createUser(phone, phone.slice(-6)); -// isNew = true; -// } -// const token = await user.createToken(null, 'season'); -// return { ...token, isNew }; -// } -// static initializeUser = initializeUser; -// static createDemoUser = createDemoUser; -// } - -// useContextKey('UserModel', () => UserServices); - import { User, UserInit, UserServices } from '@kevisual/code-center-module/models'; export { User, UserInit, UserServices }; import { OrgInit } from '@kevisual/code-center-module/models'; diff --git a/src/modules/config.ts b/src/modules/config.ts new file mode 100644 index 0000000..5abcef8 --- /dev/null +++ b/src/modules/config.ts @@ -0,0 +1,13 @@ +import path from 'path'; +import dotenv from 'dotenv'; + +const envFiles = [ + path.resolve(process.cwd(), '.env.dev'), + path.resolve(process.cwd(), '.env'), +]; +dotenv.config({ + path: envFiles, +}); + +export const config = process.env; +export const port = config.PORT || 4005; diff --git a/src/modules/domain.ts b/src/modules/domain.ts index 420ea16..c82171b 100644 --- a/src/modules/domain.ts +++ b/src/modules/domain.ts @@ -1,11 +1,5 @@ -import { useConfig } from '@kevisual/use-config'; - -type MinioConfig = { - domain: string; -}; -const config = useConfig(); /** * 用来放cookie的域名 */ -export const domain = config.domain || ''; // 请在这里填写你的域名 +export const domain = process.env.DOMAIN || ''; // 请在这里填写你的域名 diff --git a/src/modules/minio.ts b/src/modules/minio.ts index 5f871ec..a648051 100644 --- a/src/modules/minio.ts +++ b/src/modules/minio.ts @@ -1,14 +1,15 @@ import { Client, ClientOptions } from 'minio'; -import { useConfig } from '@kevisual/use-config'; -type MinioConfig = { - minio: ClientOptions & { bucketName: string }; +const minioConfig = { + endPoint: process.env.MINIO_ENDPOINT || 'localhost', + port: parseInt(process.env.MINIO_PORT || '9000'), + useSSL: process.env.MINIO_USE_SSL === 'true', + accessKey: process.env.MINIO_ACCESS_KEY, + secretKey: process.env.MINIO_SECRET_KEY, }; -const config = useConfig(); +export const minioClient = new Client(minioConfig); -const { bucketName, ...minioRest } = config.minio; -export const minioClient = new Client(minioRest); -export { bucketName }; +export const bucketName = process.env.MINIO_BUCKET_NAME || 'resources'; if (!minioClient) { throw new Error('Minio client not initialized'); } diff --git a/src/modules/redis.ts b/src/modules/redis.ts index e83ff13..399f9af 100644 --- a/src/modules/redis.ts +++ b/src/modules/redis.ts @@ -1,9 +1,5 @@ import { Redis } from 'ioredis'; -import { useConfig } from '@kevisual/use-config'; -const config = useConfig<{ - redis: ConstructorParameters; -}>(); // 配置 Redis 连接 export const redis = new Redis({ host: 'localhost', // Redis 服务器的主机名或 IP 地址 @@ -16,7 +12,6 @@ export const redis = new Redis({ return Math.min(times * 50, 2000); // 每次重试时延迟增加 }, maxRetriesPerRequest: null, // 允许请求重试的次数 (如果需要无限次重试) - ...config.redis, }); // 监听连接事件 @@ -31,4 +26,3 @@ redis.on('error', (err) => { // 初始化 Redis 客户端 export const redisPublisher = new Redis(); // 用于发布消息 export const redisSubscriber = new Redis(); // 用于订阅消息 - diff --git a/src/modules/self-restart.ts b/src/modules/self-restart.ts index 34cc101..4531092 100644 --- a/src/modules/self-restart.ts +++ b/src/modules/self-restart.ts @@ -1,11 +1,7 @@ -import { useConfig } from '@kevisual/use-config'; import childProcess from 'child_process'; -const config = useConfig<{ - appName: string; -}>(); export const selfRestart = async () => { - const appName = config.appName || 'codecenter'; + const appName = 'codecenter'; // 检测 pm2 是否安装和是否有 appName 这个应用 try { const res = childProcess.execSync(`pm2 list`); diff --git a/src/modules/sequelize.ts b/src/modules/sequelize.ts index 61c8d9d..a57d953 100644 --- a/src/modules/sequelize.ts +++ b/src/modules/sequelize.ts @@ -1,7 +1,6 @@ -import { useConfig } from '@kevisual/use-config'; import { Sequelize } from 'sequelize'; - -type PostgresConfig = { +import { config } from './config.ts'; +export type PostgresConfig = { postgres: { username: string; password: string; @@ -10,14 +9,17 @@ type PostgresConfig = { database: string; }; }; -const config = useConfig(); - -const postgresConfig = config.postgres; - -if (!postgresConfig) { - console.error('postgres config is required'); +if (!config.POSTGRES_PASSWORD || !config.POSTGRES_USER) { + console.error('postgres config is required password and user'); process.exit(1); } +const postgresConfig = { + username: config.POSTGRES_USER, + password: config.POSTGRES_PASSWORD, + host: config.POSTGRES_HOST || 'localhost', + port: parseInt(config.POSTGRES_PORT || '5432'), + database: config.POSTGRES_DB || 'postgres', +}; // connect to db export const sequelize = new Sequelize({ dialect: 'postgres', diff --git a/src/routes/github/lib/get-token.ts b/src/routes/github/lib/get-token.ts index bee60f9..c8a36d4 100644 --- a/src/routes/github/lib/get-token.ts +++ b/src/routes/github/lib/get-token.ts @@ -1,5 +1,5 @@ import fetch from 'node-fetch'; -import { useConfig } from '@kevisual/use-config'; +import { useConfig } from '@kevisual/use-config/env'; type GithubConfig = { clientId: string; diff --git a/submodules/pay-center-code b/submodules/pay-center-code index 951280f..0db28ae 160000 --- a/submodules/pay-center-code +++ b/submodules/pay-center-code @@ -1 +1 @@ -Subproject commit 951280f0975f9c46a465d45919250fd2d49503fd +Subproject commit 0db28aecde061c597338839408d848ecfe59efdf