This commit is contained in:
2025-05-03 21:12:58 +08:00
parent c2a0623482
commit d6014b3c40
19 changed files with 115 additions and 35 deletions

33
src/services/xhs-task.ts Normal file
View File

@@ -0,0 +1,33 @@
import { Queue } from 'bullmq';
import { app } from '@kevisual/xhs/index';
import { QueryRouterServer } from '@kevisual/router';
type XhsTaskOptions = {
queue: Queue;
};
export class XhsTask {
queue: Queue;
constructor(opts: XhsTaskOptions) {
this.queue = opts.queue;
}
async getUnread() {
const res = await app.call({
path: 'mention',
key: 'getUnread',
});
}
}
const qs = new QueryRouterServer();
qs.route({
path: 'task',
key: 'getUnread',
})
.define(async (ctx) => {
const unread_count = 0;
if (unread_count > 0) {
}
})
.addTo(qs);

View File

@@ -1,2 +1,3 @@
// https://edith.xiaohongshu.com/api/sns/web/unread_count
export const XHS_GET_UNREAD = 'unread_count';
export const XHS_QUEUE_NAME = 'XHS_QUEUE';

View File

@@ -1,7 +1,8 @@
import { redis } from '@/modules/redis.ts';
import { Queue } from 'bullmq';
import { nanoid } from 'nanoid';
const XHS_QUEUE_NAME = 'XHS_QUEUE';
import { XHS_QUEUE_NAME } from '@/task/common.ts';
export const queue = new Queue(XHS_QUEUE_NAME, {
connection: redis,
});

15
src/test/router.ts Normal file
View File

@@ -0,0 +1,15 @@
import { App, QueryRouterServer } from '@kevisual/router';
export const app = new App();
app
.route({
path: 'k',
key: 'k',
})
.define(async (ctx) => {
ctx.body = 'hello world';
})
.addTo(app);
const res = await app.router.queryRoute({ path: 'k', key: 'k' });
console.log('res', res);