* fix: how we fetch profiles in the buffer * perf: optimize event buffer * remove unused file * fix * wip * wip: try groupmq 2 * try simplified event buffer with duration calculation on the fly instead
38 lines
965 B
TypeScript
38 lines
965 B
TypeScript
import type { FastifyPluginCallback } from 'fastify';
|
|
import { fetchDeviceId, handler } from '@/controllers/track.controller';
|
|
import { clientHook } from '@/hooks/client.hook';
|
|
import { duplicateHook } from '@/hooks/duplicate.hook';
|
|
import { isBotHook } from '@/hooks/is-bot.hook';
|
|
|
|
const trackRouter: FastifyPluginCallback = async (fastify) => {
|
|
fastify.addHook('preValidation', duplicateHook);
|
|
fastify.addHook('preHandler', clientHook);
|
|
fastify.addHook('preHandler', isBotHook);
|
|
|
|
fastify.route({
|
|
method: 'POST',
|
|
url: '/',
|
|
handler,
|
|
});
|
|
|
|
fastify.route({
|
|
method: 'GET',
|
|
url: '/device-id',
|
|
handler: fetchDeviceId,
|
|
schema: {
|
|
response: {
|
|
200: {
|
|
type: 'object',
|
|
properties: {
|
|
deviceId: { type: 'string' },
|
|
sessionId: { type: 'string' },
|
|
message: { type: 'string', optional: true },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
};
|
|
|
|
export default trackRouter;
|