From 850cfb7ec0ce8f6fb8c1f9176f59aca22c7efdf5 Mon Sep 17 00:00:00 2001 From: vigdorov Date: Mon, 10 Aug 2020 20:51:58 +0300 Subject: [PATCH] =?UTF-8?q?HM-110.=20=D0=9D=D0=B0=D1=83=D1=87=D0=B8=D0=BB?= =?UTF-8?q?=D0=B8=20=D1=81=D0=B2=D0=B0=D0=B3=D0=B5=D1=80=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=B0=D1=82=D1=8C=20=D1=81=20=D1=82=D0=BE?= =?UTF-8?q?=D0=BA=D0=B5=D0=BD=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 7 ++++++- src/users/users.contoller.ts | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index dc4098b..3a8519e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -13,7 +13,7 @@ const initAdmin = async () => { password: String, is_admin: Boolean, }); - + const Model = mongoose.model('users', schema); await Model.deleteOne({login: 'admin'}); const salt = await bcrypt.genSalt(10); @@ -33,6 +33,11 @@ async function bootstrap() { const app = await NestFactory.create(AppModule); const options = new DocumentBuilder() + .addSecurity('apiKey', { + type: 'apiKey', + in: 'header', + name: 'Authorization', + }) .setTitle('Auth API') .setDescription('API для авторизации приложений и работы с пользователями') .setVersion('1.0.0') diff --git a/src/users/users.contoller.ts b/src/users/users.contoller.ts index b8709ac..fe23527 100644 --- a/src/users/users.contoller.ts +++ b/src/users/users.contoller.ts @@ -1,6 +1,6 @@ import {Controller, Get, Req, Post, Options, Header, Delete, HttpCode, Put} from '@nestjs/common'; -import {ApiResponse, ApiTags, ApiParam, ApiBody} from '@nestjs/swagger'; +import {ApiResponse, ApiTags, ApiParam, ApiBody, ApiSecurity} from '@nestjs/swagger'; import { ALLOW_ORIGIN_ALL, ALLOW_METHOD, @@ -37,6 +37,7 @@ import { } from './users.responses'; import {AuthService} from 'src/auth/auth.service'; +@ApiSecurity('apiKey') @Controller(USERS_CONTROLLER) @ApiTags(USERS_CONTROLLER) export class UsersController {