add test and update router version
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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>>;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user