add test and update router version

This commit is contained in:
2024-10-15 19:36:30 +08:00
parent 64f89b60dc
commit ce576ebaf1
5 changed files with 406 additions and 630 deletions

View File

@@ -1,6 +1,6 @@
import { sequelize } from '../../../modules/sequelize.ts';
import { DataTypes, Model } from 'sequelize';
import { AppData, AppType } from './app.ts';
import { AppData, AppType, AppStatus } from './app.ts';
export type AppList = Partial<InstanceType<typeof AppListModel>>;
@@ -13,6 +13,7 @@ export class AppListModel extends Model {
declare version: string;
declare key: string;
declare uid: string;
declare status: string;
}
AppListModel.init(
@@ -38,6 +39,10 @@ AppListModel.init(
type: DataTypes.UUID,
allowNull: true,
},
status: {
type: DataTypes.STRING,
defaultValue: 'running',
},
},
{
sequelize,

View File

@@ -5,7 +5,10 @@ export interface AppData {
files: { name: string; path: string }[];
}
export type AppType = 'web-single' | 'web-module';
export enum AppStatus {
running = 'running',
stop = 'stop',
}
export type App = Partial<InstanceType<typeof AppModel>>;
/**

View File

@@ -118,3 +118,21 @@ app
return ctx;
})
.addTo(app);
app
.route({
path: 'user-app',
key: 'test',
})
.define(async (ctx) => {
const id = ctx.query.id;
if (!id) {
throw new CustomError('id is required');
}
const am = await AppListModel.findByPk(id);
if (!am) {
throw new CustomError('app not found');
}
ctx.body = am;
})
.addTo(app);