generated from tailored/router-template
base module
This commit is contained in:
10
src/route/client/check.ts
Normal file
10
src/route/client/check.ts
Normal 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
25
src/route/config/index.ts
Normal 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
3
src/route/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import './shop-install/index.ts';
|
||||
import './client/check.ts';
|
||||
import './config/index.ts';
|
||||
40
src/route/shop-install/index.ts
Normal file
40
src/route/shop-install/index.ts
Normal 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);
|
||||
Reference in New Issue
Block a user