group events

This commit is contained in:
Bastian Wagner
2025-12-19 13:14:04 +01:00
parent 5a08e2319f
commit e05ab13d0d
16 changed files with 442 additions and 101 deletions

View File

@@ -1,15 +1,43 @@
import { Body, Controller, Post } from "@nestjs/common";
import { Body, Controller, Get, Param, Patch, Post } from "@nestjs/common";
import { CreateGroupDto } from "../dto/create-group.dto";
import { GroupsService } from "../application/groups.service";
import { RenameGroupDto } from "../dto/rename-group.dto";
import { IncomingEventDto } from "src/model/dto/incoming-event.dto";
import { ulid } from 'ulid';
@Controller({path: 'groups'})
export class GroupsController {
constructor(private groupsService: GroupsService) {}
@Get()
getGroups() {
return this.groupsService.getAll();
}
@Post()
createGroup(@Body() dto: CreateGroupDto) {
return this.groupsService.create(dto);
}
createGroup(@Body() dto: CreateGroupDto) {
return this.groupsService.create(dto);
}
@Patch(':id/name')
rename(@Param('id') id: string, @Body() dto: RenameGroupDto) {
// actorId später z.B. aus Header/Cookie ziehen
const event: IncomingEventDto = {
id: ulid(),
payload: { to: dto.name },
type: 'GROUP_RENAMED',
actorId: undefined
}
return this.ingest(id, [event])
}
@Post(':groupId/events/batch')
ingest(
@Param('groupId') groupId: string,
@Body() events: IncomingEventDto[],
) {
return this.groupsService.ingestEvents(groupId, events);
}
}