import { Body, Controller, Get, Param, Post, Put } from '@nestjs/common'; import { TeamService, type CreateMemberInput, type CreatedMember, type UpdateMemberInput, } from './team.service'; // REST wrapper around TeamService. Mounted at /api/team/*. // The Team wizard step on the frontend posts here instead of firing // the platform's sendInvitations mutation directly. @Controller('api/team') export class TeamController { constructor(private team: TeamService) {} @Post('members') async createMember(@Body() body: CreateMemberInput): Promise { return this.team.createMember(body); } @Put('members/:id') async updateMember( @Param('id') id: string, @Body() body: UpdateMemberInput, ): Promise<{ id: string }> { return this.team.updateMember(id, body); } // Returns the cached plaintext temp password for a recently-created // member if it's still within its 24h TTL, or { password: null } // on cache miss. Used by the wizard's right-pane copy icon when // its in-browser memory was wiped by a refresh. @Get('members/:id/temp-password') async getTempPassword(@Param('id') id: string): Promise<{ password: string | null }> { const password = await this.team.getTempPassword(id); return { password }; } }