Spaces:
Paused
Paused
File size: 715 Bytes
1fe7075 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import { Controller, Get, UseGuards } from '@nestjs/common';
import { GenerationsService } from '../generations/generations.service.js';
import { CurrentAuth } from './decorators/current-auth.decorator.js';
import { MeDto, UserDto } from './dto/me.dto.js';
import { ClerkAuthGuard } from './guards/clerk-auth.guard.js';
import type { AuthContext } from './interfaces/authenticated-request.interface.js';
@Controller('me')
@UseGuards(ClerkAuthGuard)
export class UsersController {
constructor(private readonly generations: GenerationsService) {}
@Get()
async me(@CurrentAuth() { user }: AuthContext): Promise<MeDto> {
return { user: UserDto.from(user), usage: await this.generations.usage(user) };
}
}
|