feat: add download micro-app for cli

This commit is contained in:
2025-03-11 11:04:10 +08:00
parent 7b25dbdf08
commit 1c820c3083
8 changed files with 186 additions and 155 deletions

View File

@@ -241,8 +241,15 @@ app
key: 'getApp',
})
.define(async (ctx) => {
const { user, key } = ctx.query.data;
const app = await AppModel.findOne({ where: { user, key } });
const { user, key, id } = ctx.query.data;
let app;
if (id) {
app = await AppModel.findByPk(id);
} else if (user && key) {
app = await AppModel.findOne({ where: { user, key } });
} else {
throw new CustomError('user or key is required');
}
if (!app) {
throw new CustomError('app not found');
}

View File

@@ -27,10 +27,15 @@ app
description: 'Get a single micro app upload',
})
.define(async (ctx) => {
const { id } = ctx.query;
const upload = await MicroAppUploadModel.findOne({
where: { id },
});
const { id, title } = ctx.query;
let upload: MicroAppUploadModel | null = null;
if (id) {
upload = await MicroAppUploadModel.findByPk(id);
} else if (title) {
upload = await MicroAppUploadModel.findOne({
where: { title },
});
}
if (upload) {
ctx.body = upload;
} else {