Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions apps/backend/src/routes/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
import type { FastifyInstance, FastifyRequest } from 'fastify';

export async function analyticsRoutes(app: FastifyInstance) {

app.get('/overview', {
preHandler: [app.authenticate],
}, async (request: FastifyRequest, reply: FastifyReply) => {
export async function analyticsRoutes(app: FastifyInstance): Promise<void> {
app.addHook('preHandler', (request, reply) => app.authenticate(request, reply));

app.get('/overview', async (request: FastifyRequest) => {
const userId = (request.user as any).id;

const today = new Date();
Expand Down Expand Up @@ -57,9 +56,7 @@ export async function analyticsRoutes(app: FastifyInstance) {
};
});

app.get('/views', {
preHandler: [app.authenticate],
}, async (request: FastifyRequest<{ Querystring: { page?: string, cardId?: string } }>, reply: FastifyReply) => {
app.get('/views', async (request: FastifyRequest<{ Querystring: { page?: string, cardId?: string } }>) => {
const userId = (request.user as any).id;
const page = parseInt(request.query.page || '1', 10);
const limit = 20;
Expand Down