base module

This commit is contained in:
2025-03-10 10:21:14 +08:00
parent 479eaccf57
commit b966ea68f2
40 changed files with 1594 additions and 73 deletions

10
src/route/client/check.ts Normal file
View File

@@ -0,0 +1,10 @@
import { app } from '@/app.ts';
app
.route({
path: 'check',
})
.define(async (ctx) => {
ctx.body = 'ok';
})
.addTo(app);

25
src/route/config/index.ts Normal file
View File

@@ -0,0 +1,25 @@
import { app } from '@/app.ts';
import { getCacheAssistantConfig, setConfig } from '@/modules/config/index.ts';
app
.route({
path: 'config',
description: '获取配置',
})
.define(async (ctx) => {
ctx.body = getCacheAssistantConfig();
})
.addTo(app);
app
.route({
path: 'config',
key: 'set',
description: '设置配置',
})
.define(async (ctx) => {
const { data } = ctx.query;
ctx.body = setConfig(data);
})
.addTo(app);

3
src/route/index.ts Normal file
View File

@@ -0,0 +1,3 @@
import './shop-install/index.ts';
import './client/check.ts';
import './config/index.ts';

View File

@@ -0,0 +1,40 @@
import { app } from '@/app.ts';
import { getInstallList, installApp, uninstallApp } from '@/modules/install.ts';
app
.route({
path: 'shop',
key: 'list-installed',
})
.define(async (ctx) => {
// https://localhost:51015/client/router?path=shop&key=list-installed
const list = await getInstallList();
ctx.body = list;
})
.addTo(app);
app
.route({
path: 'shop',
key: 'install',
})
.define(async (ctx) => {
// https://localhost:51015/client/router?path=shop&key=install
const { pkg } = ctx.query.data;
const res = await installApp(pkg);
ctx.body = res;
})
.addTo(app);
app
.route({
path: 'shop',
key: 'uninstall',
})
.define(async (ctx) => {
// https://localhost:51015/client/router?path=shop&key=uninstall
const { pkg } = ctx.query.data;
const res = await uninstallApp(pkg);
ctx.body = res;
})
.addTo(app);