good forst commit
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import { Body, Controller, Delete, Get, Param, Post } from '@nestjs/common';
|
||||
import { MyService } from './my.service';
|
||||
import { MemberAuth } from '../auth/member-auth.decorator';
|
||||
import { CurrentMember } from '../auth/current-member.decorator';
|
||||
import type { MemberJwtPayload } from '@tower/types';
|
||||
import { IsArray, IsInt, IsOptional, IsString, Min } from 'class-validator';
|
||||
import { ConsentScope, MemberOptOutReason } from '@tower/types';
|
||||
|
||||
class OptOutDto {
|
||||
@IsString() @IsOptional() groupId?: string;
|
||||
@IsArray() @IsOptional() scopes?: ConsentScope[];
|
||||
@IsString() @IsOptional() reason?: MemberOptOutReason;
|
||||
@IsString() @IsOptional() notes?: string;
|
||||
}
|
||||
|
||||
class OptInDto {
|
||||
@IsString() groupId!: string;
|
||||
@IsArray() scopes!: ConsentScope[];
|
||||
@IsInt() @Min(1) @IsOptional() retentionDays?: number;
|
||||
}
|
||||
|
||||
@Controller('my')
|
||||
@MemberAuth()
|
||||
export class MyController {
|
||||
constructor(private readonly service: MyService) {}
|
||||
|
||||
@Get('profile')
|
||||
profile(@CurrentMember() member: MemberJwtPayload) {
|
||||
return this.service.getProfile(member.sub, member.tenantId);
|
||||
}
|
||||
|
||||
@Get('groups')
|
||||
listGroups(@CurrentMember() member: MemberJwtPayload) {
|
||||
return this.service.listGroups(member.sub, member.tenantId);
|
||||
}
|
||||
|
||||
@Get('groups/:id')
|
||||
getGroup(@CurrentMember() member: MemberJwtPayload, @Param('id') id: string) {
|
||||
return this.service.getGroup(member.sub, member.tenantId, id);
|
||||
}
|
||||
|
||||
@Post('opt-out')
|
||||
optOut(@CurrentMember() member: MemberJwtPayload, @Body() body: OptOutDto) {
|
||||
return this.service.optOut(member.sub, member.tenantId, body);
|
||||
}
|
||||
|
||||
@Post('opt-in')
|
||||
optIn(@CurrentMember() member: MemberJwtPayload, @Body() body: OptInDto) {
|
||||
return this.service.optIn(member.sub, member.tenantId, body);
|
||||
}
|
||||
|
||||
@Delete('account')
|
||||
deleteAccount(@CurrentMember() member: MemberJwtPayload) {
|
||||
return this.service.deleteAccount(member.sub, member.tenantId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user