File size: 1,069 Bytes
7b850b7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
import {
Body,
Controller,
Get,
HttpStatus,
Post,
Query,
Req,
Res,
UseGuards,
} from '@nestjs/common';
import { UserService } from './user.service';
import { Response } from 'express';
import { CommonServices } from '../shared/common.service';
import { JwtAuthGuard } from '../auth/jwt-auth.guard'
@Controller('user')
export class UserController extends CommonServices {
constructor(
private readonly userService: UserService,
) {
super();
}
@Get('')
@UseGuards(JwtAuthGuard)
async getUserDetails(@Res() res: Response, @Req() req): Promise<any> {
try {
const response = await this.userService.userRepository.findById(
req.user.userId,
);
return this.sendResponse(
this.messages.Success,
response ?? 'NOT_FOUND',
HttpStatus.OK,
res,
);
} catch (error) {
return this.sendResponse(
'Internal server Error',
{},
HttpStatus.INTERNAL_SERVER_ERROR,
res,
);
}
}
}
|