diff --git a/package.json b/package.json index 46c6cad..dcbf86d 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,20 @@ { - "name": "var-proxy", + "name": "page-proxy", "version": "0.0.1", "description": "", "main": "index.js", "type": "module", + "app": { + "key": "page-proxy", + "entry": "dist/app.mjs", + "type": "micro-app", + "files": [ + "dist" + ] + }, + "files": [ + "dist" + ], "scripts": { "dev": "cross-env NODE_ENV=development nodemon --ignore upload --exec tsx src/index.ts", "build": "rimraf dist && rollup -c", @@ -15,25 +26,24 @@ "author": "", "license": "ISC", "devDependencies": { - "@rollup/plugin-commonjs": "^28.0.0", + "@rollup/plugin-commonjs": "^28.0.1", "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^15.3.0", - "@rollup/plugin-typescript": "^12.1.0", + "@rollup/plugin-typescript": "^12.1.1", "@types/http-proxy": "^1.17.15", - "@types/node": "^22.7.5", + "@types/node": "^22.10.1", "cross-env": "^7.0.3", "nodemon": "^3.1.7", - "rollup": "^4.24.0", - "ts-lib": "^0.0.5", - "tslib": "^2.7.0", - "typescript": "^5.6.3" + "rollup": "^4.27.4", + "tslib": "^2.8.1", + "typescript": "^5.7.2" }, "dependencies": { - "@abearxiong/router": "0.0.1-alpha.43", - "@abearxiong/use-config": "^0.0.2", + "@kevisual/router": "0.0.6-alpha-2", + "@kevisual/use-config": "^1.0.3", "@abearxiong/use-file-store": "^0.0.1", "ioredis": "^5.4.1", - "nanoid": "^5.0.7" + "nanoid": "^5.0.9" }, "resolutions": { "picomatch": "^4.0.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0dece01..2c8dfc1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,7 +14,7 @@ importers: '@abearxiong/router': specifier: 0.0.1-alpha.43 version: 0.0.1-alpha.43 - '@abearxiong/use-config': + '@kevisual/use-config': specifier: ^0.0.2 version: 0.0.2 '@abearxiong/use-file-store': @@ -66,8 +66,8 @@ packages: '@abearxiong/router@0.0.1-alpha.43': resolution: {integrity: sha512-umwi4T5s54Zb8ItseGw3uB7PDG8BqnHyAughlXH2dhub4f49fO+rwR+Zth7scUONkmc21Z27/lPgLBHXrYOkYw==, tarball: https://npm.pkg.github.com/download/@abearxiong/router/0.0.1-alpha.43/287c6e2597b36c5e3ed351b473e38f468b5f49ea} - '@abearxiong/use-config@0.0.2': - resolution: {integrity: sha512-IBOmeP46ykbDlkplFS65UsAHjyPDKnvS2oqbkpLWhbSwDbF5zhBnD4ibsFZKPCyc3lMlPeRqYva4x6puX3E/qQ==, tarball: https://npm.pkg.github.com/download/@abearxiong/use-config/0.0.2/59fbeec8c8e086ec48e55024fe39020b079e6fa5} + '@kevisual/use-config@0.0.2': + resolution: {integrity: sha512-IBOmeP46ykbDlkplFS65UsAHjyPDKnvS2oqbkpLWhbSwDbF5zhBnD4ibsFZKPCyc3lMlPeRqYva4x6puX3E/qQ==, tarball: https://npm.pkg.github.com/download/@kevisual/use-config/0.0.2/59fbeec8c8e086ec48e55024fe39020b079e6fa5} '@abearxiong/use-file-store@0.0.1': resolution: {integrity: sha512-65ZQBHxwr76sAFG+Xd4IQstx8dERhkaX5MLqtqJ0f9m+2NnS/klNe0t4q9tgjMWAEWQxHjnPShpHWzkCENaDnQ==, tarball: https://npm.pkg.github.com/download/@abearxiong/use-file-store/0.0.1/f171e398c078d4940c1ddedf5ad529d17b0eec32} @@ -830,7 +830,7 @@ snapshots: - bufferutil - utf-8-validate - '@abearxiong/use-config@0.0.2': {} + '@kevisual/use-config@0.0.2': {} '@abearxiong/use-file-store@0.0.1(typescript@5.6.3)': dependencies: diff --git a/rollup.config.js b/rollup.config.js index 392993f..97cca9e 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -11,7 +11,7 @@ import json from '@rollup/plugin-json'; export default { input: 'src/index.ts', // TypeScript 入口文件 output: { - file: 'dist/app.js', // 输出文件 + file: 'dist/app.mjs', // 输出文件 format: 'es', // 输出格式设置为 ES 模块 }, plugins: [ @@ -26,4 +26,5 @@ export default { }), // 使用 @rollup/plugin-typescript 处理 TypeScript 文件 ], // external: ['ws'], + external: ['ioredis', '@kevisual/router', '@kevisual/use-config'], }; diff --git a/src/app.ts b/src/app.ts index 3ec3f24..96d2648 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,4 +1,4 @@ -import { App } from '@abearxiong/router'; +import { App } from '@kevisual/router'; export const app = new App({ serverOptions: { diff --git a/src/index.ts b/src/index.ts index d69a418..ccd12c3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import { handleRequest } from './module/index.ts'; -import { useConfig } from '@abearxiong/use-config'; +import { useConfig } from '@kevisual/use-config'; import { app } from './app.ts'; import './route/route.ts' const { port } = useConfig<{ port: number }>(); diff --git a/src/module/get-user-app.ts b/src/module/get-user-app.ts index 4e40130..2d508f1 100644 --- a/src/module/get-user-app.ts +++ b/src/module/get-user-app.ts @@ -1,7 +1,7 @@ import path from 'path'; import { redis, subscriber } from './redis/redis.ts'; import { useFileStore } from '@abearxiong/use-file-store'; -import { useConfig } from '@abearxiong/use-config'; +import { useConfig } from '@kevisual/use-config'; import fs from 'fs'; import crypto from 'crypto'; import { nanoid } from 'nanoid'; diff --git a/src/module/index.ts b/src/module/index.ts index fd8e4c8..fb7ffff 100644 --- a/src/module/index.ts +++ b/src/module/index.ts @@ -4,7 +4,7 @@ import { UserApp } from './get-user-app.ts'; import { useFileStore } from '@abearxiong/use-file-store'; import path from 'path'; import fs from 'fs'; -import { useConfig } from '@abearxiong/use-config'; +import { useConfig } from '@kevisual/use-config'; import { redis } from './redis/redis.ts'; import { getContentType } from './get-content-type.ts'; import { sleep } from '@/utils/sleep.ts'; diff --git a/src/module/query/get-router.ts b/src/module/query/get-router.ts index 6a09735..4e92eca 100644 --- a/src/module/query/get-router.ts +++ b/src/module/query/get-router.ts @@ -1,4 +1,4 @@ -import { useConfig } from '@abearxiong/use-config'; +import { useConfig } from '@kevisual/use-config'; const { resources, api } = useConfig<{ resources: string; diff --git a/src/module/redis/redis.ts b/src/module/redis/redis.ts index 0f9ee16..6fec661 100644 --- a/src/module/redis/redis.ts +++ b/src/module/redis/redis.ts @@ -1,5 +1,5 @@ import { Redis } from 'ioredis'; -import { useConfig } from '@abearxiong/use-config'; +import { useConfig } from '@kevisual/use-config'; const config = useConfig<{ redis: ConstructorParameters; diff --git a/src/route/app/list.ts b/src/route/app/list.ts index 6330b5e..04db670 100644 --- a/src/route/app/list.ts +++ b/src/route/app/list.ts @@ -1,7 +1,6 @@ import { UserApp } from '@/module/get-user-app.ts'; import { app } from '../../app.ts'; import { redis } from '@/module/redis/redis.ts'; -import { CustomError } from '@abearxiong/router'; import fs from 'fs'; import { useFileStore } from '@abearxiong/use-file-store'; const fileStore = useFileStore('upload'); @@ -34,7 +33,7 @@ app await userApp.clearCacheData(); } catch (error) { console.error(error); - throw new CustomError('删除失败'); + ctx.throw('删除失败'); } ctx.body = 'successfully'; }) @@ -83,16 +82,16 @@ app const { user, app } = ctx.query.data || {}; if (!user || !app) { if (!user) { - throw new CustomError('user is required'); + ctx.throw('user is required'); } if (!app) { - throw new CustomError('app is required'); + ctx.throw('app is required'); } } const userApp = new UserApp({ user, app }); const cache = await userApp.getCache(); if (!cache) { - throw new CustomError('Not Found App'); + ctx.throw('Not Found App'); } ctx.body = cache; })