File size: 1,058 Bytes
3d23b0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { FastifyRequest, FastifyReply } from 'fastify';
import * as service from '../services';

export async function getTrendingDiscussHandler(
    request: FastifyRequest<{ Querystring: { first?: string } }>,
    reply: FastifyReply
) {
    const first = parseInt(request.query.first || '20', 10);
    const data = await service.getTrendingDiscuss(first);
    return reply.send(data);
}

export async function getDiscussTopicHandler(
    request: FastifyRequest<{ Params: { topicId: string } }>,
    reply: FastifyReply
) {
    const topicId = parseInt(request.params.topicId, 10);
    const data = await service.getDiscussTopic(topicId);
    return reply.send(data);
}

export async function getDiscussCommentsHandler(
    request: FastifyRequest<{ Params: { topicId: string }; Querystring: any }>,
    reply: FastifyReply
) {
    const topicId = parseInt(request.params.topicId, 10);
    const query = (request.query || {}) as Record<string, any>;
    const data = await service.getDiscussComments({ topicId, ...query });
    return reply.send(data);
}