mirror of
https://github.com/n08i40k/schedule-parser-next.git
synced 2025-12-06 09:47:46 +03:00
- Add VKIDModule - Define vkIdConstants in constants.ts - Create OAuthRequestDto for VKID - Create OAuthResponseDto for VKID
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
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;
|
||
}
|
||
}
|