mirror of
https://github.com/n08i40k/schedule-parser-next.git
synced 2025-12-06 17:57:45 +03:00
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:
43
src/vkid/vkid.controller.ts
Normal file
43
src/vkid/vkid.controller.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user