import { Controller, Get, Param, NotFoundException } from '@nestjs/common'; import { UsersService } from 'src/services/user.service'; import { RegisteredUser } from 'src/interface/interface'; @Controller('users') export class UsersController { constructor(private readonly usersService: UsersService) {} // GET /users/:id → Fetch user by ID @Get(':id') async getUserById(@Param('id') id: string): Promise> { const user = await this.usersService.findById(id); if (!user) { throw new NotFoundException(`User with ID ${id} not found`); } const { password, ...safeUser } = user; return safeUser; } // GET /users → (Optional) List all users (for debugging) @Get() getAllUsers(): Omit[] { return this.usersService.getAllUsers(); } }