37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
|
|
import { Controller, Get, Patch, Body, UseGuards, Req } from '@nestjs/common';
|
||
|
|
import { UsersService } from './users.service';
|
||
|
|
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
||
|
|
import { ApiTags, ApiOperation } from '@nestjs/swagger';
|
||
|
|
|
||
|
|
@ApiTags('users')
|
||
|
|
@Controller('me')
|
||
|
|
@UseGuards(JwtAuthGuard)
|
||
|
|
export class UsersController {
|
||
|
|
constructor(private usersService: UsersService) {}
|
||
|
|
|
||
|
|
@Get()
|
||
|
|
@ApiOperation({ summary: 'Get current user profile' })
|
||
|
|
async getProfile(@Req() req: any) {
|
||
|
|
return this.usersService.findById(req.user.id);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Get('summary')
|
||
|
|
@ApiOperation({ summary: 'Get user dashboard summary' })
|
||
|
|
async getSummary(@Req() req: any) {
|
||
|
|
return this.usersService.getUserSummary(req.user.id);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Patch()
|
||
|
|
@ApiOperation({ summary: 'Update user profile' })
|
||
|
|
async updateProfile(@Req() req: any, @Body() updateData: any) {
|
||
|
|
return this.usersService.update(req.user.id, updateData);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Patch('billing')
|
||
|
|
@ApiOperation({ summary: 'Update billing information' })
|
||
|
|
async updateBilling(@Req() req: any, @Body() billingData: any) {
|
||
|
|
// TODO: Sync to WHMCS custom fields
|
||
|
|
throw new Error('Not implemented');
|
||
|
|
}
|
||
|
|
}
|