import { Body , ClassSerializerInterceptor , Controller , Get , Post , UseGuards , UseInterceptors } from '@nestjs/common' ; import { IJwtPayload , MemberRoleEnum } from '@notifire/shared' ; import { CreateNotificationGroup } from './usecases/create-notification-group/create-notification-group.usecase' ; import { Roles } from '../auth/framework/roles.decorator' ; import { UserSession } from '../shared/framework/user.decorator' ; import { CreateNotificationGroupCommand } from './usecases/create-notification-group/create-notification-group.command' ; import { CreateNotificationGroupDto } from './dto/create-notification-group.dto' ; import { JwtAuthGuard } from '../auth/framework/auth.guard' ; import { GetNotificationGroups } from './usecases/get-notification-groups/get-notification-groups.usecase' ; import { GetNotificationGroupsCommand } from './usecases/get-notification-groups/get-notification-groups.command' ; @ Controller ( '/notification-groups' ) @ UseInterceptors ( ClassSerializerInterceptor ) @ UseGuards ( JwtAuthGuard ) export class NotificationGroupsController { constructor ( private createNotificationGroupUsecase , private getNotificationGroupsUsecase ) { } @ Post ( '' ) @ Roles ( MemberRoleEnum . ADMIN ) createNotificationGroup ( @ UserSession ( ) user , @ Body ( ) body ) { return this . createNotificationGroupUsecase . execute ( CreateNotificationGroupCommand . create ( { organizationId : user . organizationId , userId : user . _id , applicationId : user . applicationId , name : body . name , } ) ) ; } @ Get ( '' ) @ Roles ( MemberRoleEnum . ADMIN ) getNotificationGroups ( @ UserSession ( ) user ) { return this . getNotificationGroupsUsecase . execute ( GetNotificationGroupsCommand . create ( { organizationId : user . organizationId , userId : user . _id , applicationId : user . applicationId , } ) ) ; } }