sse für live collab eingebaut
This commit is contained in:
@@ -7,22 +7,27 @@ import {
|
||||
Patch,
|
||||
Post,
|
||||
Req,
|
||||
Sse,
|
||||
UnauthorizedException,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { Observable } from 'rxjs';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
import { CreateListDto } from './dto/create-list.dto';
|
||||
import { AddListItemDto, UpdateListItemDto } from './dto/list-item.dto';
|
||||
import { UpdateListDto } from './dto/update-list.dto';
|
||||
import { ListRealtimeService } from './list-realtime.service';
|
||||
import { ListsService } from './lists.service';
|
||||
import type { AuthenticatedRequest } from '../auth/auth.types';
|
||||
import type { MessageEvent } from '@nestjs/common';
|
||||
|
||||
@Controller('lists')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class ListsController {
|
||||
constructor(
|
||||
private readonly authService: AuthService,
|
||||
private readonly listRealtimeService: ListRealtimeService,
|
||||
private readonly listsService: ListsService,
|
||||
) {}
|
||||
|
||||
@@ -39,6 +44,11 @@ export class ListsController {
|
||||
return this.listsService.listLists(this.requireUserId(request));
|
||||
}
|
||||
|
||||
@Sse('events')
|
||||
listEvents(@Req() request: AuthenticatedRequest): Observable<MessageEvent> {
|
||||
return this.listRealtimeService.eventsFor(this.requireUserId(request));
|
||||
}
|
||||
|
||||
@Get(':listId')
|
||||
getList(
|
||||
@Req() request: AuthenticatedRequest,
|
||||
|
||||
Reference in New Issue
Block a user