@thescaffold/chat-nestjs
v0.2.51
Published
NestJS module wrapping @thescaffold/chat-server for X Chat
Readme
@thescaffold/chat-nestjs
NestJS facade for X Chat. ChatModule.forRoot(options) wires a
@thescaffold/chat-server ChatServer, mounts its REST controller (GET
/v1/chat/rooms/:roomId/messages), and attaches the WebSocket upgrade
(/ws/chat) to Nest's HTTP server on module init.
@Module({
imports: [
ChatModule.forRootAsync({
useFactory: (config: ConfigService) => ({
auth: new JwtAuthAdapter({ secret: config.get('JWT_SECRET')! }),
roomStore,
messageStore,
userStore,
presence,
pubsub,
storage,
wsPath: '/ws/chat',
}),
inject: [ConfigService],
}),
],
})
export class AppModule {}The module is @Global(), so ChatService (a thin facade over the server) is
injectable anywhere without re-importing.
Pair the controller routes with an upstream auth guard that puts an
AuthIdentity on req.user; the @ChatUser() parameter decorator and
ChatMembershipGuard pick it up.
