33 lines
745 B
TypeScript
33 lines
745 B
TypeScript
import { App } from '@kevisual/router';
|
|
import { app } from './app.ts';
|
|
|
|
import './route/system-config/index.ts';
|
|
|
|
type Message = {
|
|
path: string;
|
|
key?: string;
|
|
payload?: any;
|
|
};
|
|
type Response = {
|
|
code: number;
|
|
data?: any;
|
|
message?: string;
|
|
};
|
|
export const runApp = async (msg: Message): Promise<Response> => {
|
|
try {
|
|
const { code, body, message } = await app.call(msg);
|
|
const res = { code, data: body };
|
|
if (message) {
|
|
res['message'] = message;
|
|
}
|
|
return res as { code: number; data: any; message?: string };
|
|
} catch (error) {
|
|
console.error('runApp error', error);
|
|
return { code: 500, message: error.message };
|
|
}
|
|
};
|
|
|
|
export const loadApp = async (mainApp: App) => {
|
|
mainApp.importApp(app);
|
|
};
|