30 lines
837 B
TypeScript
30 lines
837 B
TypeScript
import { Body, Controller, Get, Param, Post, Req, Session } from '@nestjs/common';
|
|
import { GroupEventsService } from '../application/group-events.service';
|
|
import { IncomingGroupEventDto } from '../dto/group-event.dto';
|
|
|
|
@Controller('group-events')
|
|
export class GroupEventsController {
|
|
|
|
constructor(private readonly groupsEventsService: GroupEventsService) {}
|
|
|
|
|
|
@Post(':groupId/events/batch')
|
|
ingest(
|
|
@Param('groupId') groupId: string,
|
|
@Body() events: IncomingGroupEventDto[],
|
|
) {
|
|
return this.groupsEventsService.ingestEvents(groupId, events);
|
|
}
|
|
|
|
@Get()
|
|
getEvents(@Session() session: Record<string, any>) {
|
|
return this.groupsEventsService.getLastEvents({});
|
|
}
|
|
|
|
@Get(':groupdId')
|
|
getGroupEvents(@Param('groupId') groupId: string) {
|
|
return this.groupsEventsService.getLastEvents({groupId});
|
|
}
|
|
|
|
}
|