вложения, канальчики, бим-бим + бам-бам

This commit is contained in:
2026-04-25 00:51:12 +06:00
parent 0b75148a3f
commit ad477ee813
61 changed files with 14636 additions and 375 deletions

View File

@@ -0,0 +1,27 @@
import type { FastifyPluginAsync } from 'fastify'
import type { Type } from 'typebox'
import type { UserSchema } from '../schemas/auth.ts'
import type { ChatMessageSchema } from '../schemas/chat.ts'
import { EventEmitter } from 'node:events'
import fp from 'fastify-plugin'
declare module 'fastify' {
interface FastifyInstance {
bus: EventEmitter
}
}
interface EventMap {
'chat:new-message': [Type.Static<typeof ChatMessageSchema>]
'user:profile-updated': [Type.Static<typeof UserSchema>]
}
const plugin: FastifyPluginAsync = fp(async (fastify) => {
const bus = new EventEmitter<EventMap>()
fastify.decorate('bus', bus)
}, {
name: 'event-bus',
})
export default plugin