Refactor AI proxy error handling and remove deprecated upload and event routes

- Updated `getAiProxy` function to return a JSON response for missing objects when the user is the owner.
- Removed the `upload.ts`, `event.ts`, and related middleware files to streamline the codebase.
- Cleaned up `handle-request.ts` and `index.ts` by removing unused imports and routes.
- Deleted chunk upload handling and related utility functions to simplify resource management.
- Enhanced app manager list functionality to support app creation if not found.
This commit is contained in:
2026-02-02 18:06:31 +08:00
parent 82e3392b36
commit 158dd9e85c
14 changed files with 92 additions and 908 deletions

View File

@@ -43,7 +43,7 @@ app
console.log('get app manager called');
const tokenUser = ctx.state.tokenUser;
const id = ctx.query.id;
const { key, version } = ctx.query?.data || {};
const { key, version, create = false } = ctx.query?.data || {};
if (!id && (!key || !version)) {
throw new CustomError('id is required');
}
@@ -59,8 +59,27 @@ app
},
});
}
if (!am && create) {
am = await AppListModel.create({
key,
version,
uid: tokenUser.id,
data: {},
});
const res = await app.run({ path: 'app', key: "detectVersionList", payload: { data: { appKey: key, version, username: tokenUser.username }, token: ctx.query.token } });
if (res.code !== 200) {
ctx.throw(res.message || 'detect version list error');
}
am = await AppListModel.findOne({
where: {
key,
version,
uid: tokenUser.id,
},
});
}
if (!am) {
throw new CustomError('app not found');
ctx.throw('app not found');
}
console.log('get app', am.id, am.key, am.version);
ctx.body = prefixFix(am, tokenUser.username);