fix: add manager config assistant-apps-config
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { app } from '@/app.ts';
|
||||
import { AppModel } from '../module/index.ts';
|
||||
import { ConfigPermission } from '@kevisual/permission';
|
||||
|
||||
// curl http://localhost:4005/api/router?path=app&key=public-list
|
||||
// TODO:
|
||||
@@ -9,15 +10,28 @@ app
|
||||
key: 'public-list',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const list = await AppModel.findAll({
|
||||
const { username = 'root', status = 'running', page = 1, pageSize = 100, order = 'DESC' } = ctx.query.data || {};
|
||||
const { rows, count } = await AppModel.findAndCountAll({
|
||||
where: {
|
||||
status: 'running',
|
||||
status,
|
||||
user: username,
|
||||
},
|
||||
// attributes: {
|
||||
// exclude: ['data'],
|
||||
// },
|
||||
attributes: {
|
||||
exclude: [],
|
||||
},
|
||||
order: [['updatedAt', order]],
|
||||
limit: pageSize,
|
||||
offset: (page - 1) * pageSize,
|
||||
distinct: true,
|
||||
logging: false,
|
||||
});
|
||||
ctx.body = list;
|
||||
ctx.body = {
|
||||
list: rows.map((item) => {
|
||||
return ConfigPermission.getDataPublicPermission(item.toJSON());
|
||||
}),
|
||||
pagination: {
|
||||
total: count,
|
||||
},
|
||||
};
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
// import { app } from '@/app.ts';
|
||||
import { manager, loadManager, app as ManagerApp } from '@kevisual/local-app-manager';
|
||||
import { fileIsExist } from '@kevisual/use-config/env';
|
||||
import path from 'path';
|
||||
const assistantAppsConfig = path.join(process.cwd(), 'assistant-apps-config.json');
|
||||
const isExist = fileIsExist(assistantAppsConfig);
|
||||
export const existDenpend = [
|
||||
'sequelize', // commonjs
|
||||
'pg', // commonjs
|
||||
@@ -16,7 +20,11 @@ export { manager };
|
||||
// console.log('app', app, );
|
||||
// console.log('app2 context', global.context);
|
||||
// console.log('app equal', app === ManagerApp);
|
||||
loadManager({ runtime: 'server' });
|
||||
if (!isExist) {
|
||||
loadManager({ runtime: 'server', configFilename: 'assistant-apps-config.json' });
|
||||
} else {
|
||||
loadManager({ runtime: 'server' });
|
||||
}
|
||||
|
||||
// middleware: ['auth-admin']
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user