Skip to content
Snippets Groups Projects
Select Git revision
22 results Searching

temp-user.controller.ts

Blame
  • temp-user.controller.ts 833 B
    import { Controller, Get, HttpException, HttpStatus, Param } from '@nestjs/common';
    import { ApiParam, ApiTags } from '@nestjs/swagger';
    import { TempUser } from './temp-user.schema';
    import { TempUserService } from './temp-user.service';
    
    @ApiTags('temp-user')
    @Controller('temp-user')
    export class TempUserController {
      constructor(private readonly tempUserService: TempUserService) {}
    
      @Get()
      public async findAll(): Promise<TempUser[]> {
        return await this.tempUserService.findAll();
      }
    
      @Get(':id')
      @ApiParam({ name: 'id', type: String, required: true })
      public async getTempUser(@Param('id') id: string): Promise<TempUser> {
        const user = await this.tempUserService.findById(id);
        if (!user) {
          throw new HttpException('Temp user does not exist', HttpStatus.BAD_REQUEST);
        }
        return user;
      }
    }