Newer
Older
import { Controller, Get, HttpException, HttpStatus, Param } from '@nestjs/common';
import { ApiParam } from '@nestjs/swagger';
import { TempUser } from './temp-user.schema';
import { TempUserService } from './temp-user.service';
@Controller('temp-user')
export class TempUserController {
constructor(private readonly tempUserSercice: TempUserService) {}
@Get(':id')
@ApiParam({ name: 'id', type: String, required: true })
public async getTempUser(@Param('id') id: string): Promise<TempUser> {
const user = await this.tempUserSercice.findById(id);
if (!user) {
throw new HttpException('Temp user does not exists', HttpStatus.BAD_REQUEST);
}
return user;
}
}