feat: add app-manager for query loading cache

This commit is contained in:
xion 2025-03-30 19:53:44 +08:00
parent b8fa48e331
commit e0ac1b7d27
4 changed files with 33 additions and 1 deletions

View File

@ -4,4 +4,6 @@ import './user-app.ts';
import './public/index.ts';
import './domain/index.ts';
import './proxy/index.ts';
export * from './module/index.ts';

View File

@ -0,0 +1 @@
import './page-proxy.ts';

View File

@ -0,0 +1,29 @@
import { app, redis } from '@/app.ts';
app
.route({
path: 'page-proxy-app',
key: 'status',
})
.define(async (ctx) => {
//
const { user, app } = ctx.query;
if (!user || !app) {
ctx.body = {
code: 400,
message: 'user and app are required',
};
return;
}
const key = `user:app:status:${app}:${user}`;
const status = await redis.get(key);
if (!status) {
ctx.throw(404, 'status not found');
}
try {
const parsedStatus = JSON.parse(status);
ctx.body = parsedStatus;
} catch (e) {
ctx.throw(400, 'status is not a valid json');
}
})
.addTo(app);

@ -1 +1 @@
Subproject commit 0c36328ac3e728e7978cca03bb187fb4e841f6d8
Subproject commit 60c5a986edd4add11b229b2d3c869dcdf32c0428