feat(backend): emit timer.created event from POST /timers route

Wire getEventBus().emit() into the timer creation handler so webhook
subscribers and future listeners receive typed domain events.
This commit is contained in:
saravanakumardb1 2026-04-13 11:50:39 -07:00
parent 82428d7bf9
commit c1972ef0d0

View File

@ -11,6 +11,7 @@
*/ */
import type { FastifyInstance } from 'fastify'; import type { FastifyInstance } from 'fastify';
import { getEventBus } from '../../lib/event-bus.js';
import { BadRequestError, NotFoundError, ConflictError } from '@bytelyst/errors'; import { BadRequestError, NotFoundError, ConflictError } from '@bytelyst/errors';
import { extractAuth } from '../../lib/auth.js'; import { extractAuth } from '../../lib/auth.js';
import * as repo from './repository.js'; import * as repo from './repository.js';
@ -106,6 +107,7 @@ export async function timerRoutes(app: FastifyInstance) {
req.log.info({ timerId: doc.id, type: doc.type }, 'Creating timer'); req.log.info({ timerId: doc.id, type: doc.type }, 'Creating timer');
const created = await repo.createTimer(doc); const created = await repo.createTimer(doc);
getEventBus().emit('timer.created', { timerId: doc.id, userId: auth.sub, label: doc.label });
reply.code(201); reply.code(201);
return created; return created;
}); });