Add VKID OAuth integration and constants

- Add VKIDModule
- Define vkIdConstants in constants.ts
- Create OAuthRequestDto for VKID
- Create OAuthResponseDto for VKID
This commit is contained in:
2025-01-26 01:14:46 +04:00
parent bf58c2b66a
commit 1b5917f651
9 changed files with 156 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
import {
Body,
Controller,
HttpStatus,
NotAcceptableException,
Post,
} from "@nestjs/common";
import { ApiBody, ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
import { VKIDService } from "./vkid.service";
import OAuthRequestDto from "./dto/oauth.request.dto";
import OAuthResponseDto from "./dto/oauth.response.dto";
import { ResultDto } from "../utility/validation/class-validator.interceptor";
@ApiTags("v1/vkid")
@Controller({ path: "vkid", version: "1" })
export class VKIDController {
constructor(private readonly vkidService: VKIDService) {}
@ApiOperation({
summary: "OAuth аутентификация",
description: "Аутентификация пользователя с использованием OAuth",
})
@ApiBody({ type: OAuthRequestDto, description: "Данные для OAuth запроса" })
@ApiResponse({
status: HttpStatus.OK,
type: OAuthResponseDto,
description: "OAuth аутентификация прошла успешно",
})
@ApiResponse({
status: HttpStatus.NOT_ACCEPTABLE,
description: "Ошибка в процессе OAuth",
})
@ResultDto(OAuthResponseDto)
@Post("oauth")
async oauth(
@Body() oAuthRequestDto: OAuthRequestDto,
): Promise<OAuthResponseDto> {
const result = await this.vkidService.oauth(oAuthRequestDto);
if (!result) throw new NotAcceptableException("OAuth process failed");
return result;
}
}