generated from tailored/router-template
temp
This commit is contained in:
33
src/services/xhs-task.ts
Normal file
33
src/services/xhs-task.ts
Normal 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);
|
||||
@@ -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';
|
||||
@@ -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
15
src/test/router.ts
Normal 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);
|
||||
Reference in New Issue
Block a user