Files
schedule-parser-next/src/vkid/vkid.controller.ts
N08I40K 1b5917f651 Add VKID OAuth integration and constants
- Add VKIDModule
- Define vkIdConstants in constants.ts
- Create OAuthRequestDto for VKID
- Create OAuthResponseDto for VKID
2025-01-26 01:14:46 +04:00

44 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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;
}
}