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:
parent
82428d7bf9
commit
c1972ef0d0
@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
import type { FastifyInstance } from 'fastify';
|
||||
import { getEventBus } from '../../lib/event-bus.js';
|
||||
import { BadRequestError, NotFoundError, ConflictError } from '@bytelyst/errors';
|
||||
import { extractAuth } from '../../lib/auth.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');
|
||||
const created = await repo.createTimer(doc);
|
||||
getEventBus().emit('timer.created', { timerId: doc.id, userId: auth.sub, label: doc.label });
|
||||
reply.code(201);
|
||||
return created;
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user