From 3883ea4ad8ef9c954497185ab5b0d9c01cd8f094 Mon Sep 17 00:00:00 2001 From: vigdorov Date: Mon, 10 Aug 2020 20:52:36 +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=D0=B0=D0=B2?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/logs/logs.controller.ts | 3 ++- src/main.ts | 5 +++++ src/store/store.controller.ts | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/logs/logs.controller.ts b/src/logs/logs.controller.ts index c8ded32..98350e8 100644 --- a/src/logs/logs.controller.ts +++ b/src/logs/logs.controller.ts @@ -1,11 +1,12 @@ import {Controller, Get, Header, Delete, Options, HttpCode, Req} from '@nestjs/common'; -import {ApiTags, ApiResponse} from '@nestjs/swagger'; +import {ApiTags, ApiResponse, ApiSecurity} from '@nestjs/swagger'; import {LogsService} from './logs.service'; import {ALLOW_ORIGIN_ALL, COLLECTION_LOGS, LOG_TYPE, ALLOW_METHOD, ALLOW_CREDENTIALS, CONTENT_LENGTH, ALLOW_HEADERS} from 'src/consts'; import {ClienLogResponse, ServerLogResponse} from './logs.schema'; import {AuthService} from 'src/services/auth.service'; import {Request} from 'express'; +@ApiSecurity('apiKey') @Controller(COLLECTION_LOGS) @ApiTags(COLLECTION_LOGS) export class LogsController { diff --git a/src/main.ts b/src/main.ts index 467ffab..22ef244 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,6 +9,11 @@ async function bootstrap() { }); const options = new DocumentBuilder() + .addSecurity('apiKey', { + type: 'apiKey', + in: 'header', + name: 'Authorization', + }) .setTitle('Storage Service API') .setDescription('API для создания хранилищ по уникальному ключу') .setVersion('1.0.0') diff --git a/src/store/store.controller.ts b/src/store/store.controller.ts index cb8f13a..ba86714 100644 --- a/src/store/store.controller.ts +++ b/src/store/store.controller.ts @@ -1,7 +1,7 @@ import {Controller, Get, Req, Post, Options, Header, Delete, HttpCode, Put, UseInterceptors} from '@nestjs/common'; import {StoreService} from './store.service'; import {Store, StoreRequest} from './store.schema'; -import {ApiResponse, ApiTags, ApiParam, ApiBody} from '@nestjs/swagger'; +import {ApiResponse, ApiTags, ApiParam, ApiBody, ApiBearerAuth, ApiSecurity} from '@nestjs/swagger'; import {ALLOW_ORIGIN_ALL, ALLOW_METHOD, ALLOW_CREDENTIALS, CONTENT_LENGTH, ALLOW_HEADERS, COLLECTION_STORE} from 'src/consts'; import {Request} from 'express'; import {LoggingInterceptor} from 'src/logs/logging.interceptor'; @@ -31,6 +31,7 @@ const makeApiHeader = (request: Request): string => { return typeof apiHeader === 'string' ? apiHeader : ''; }; +@ApiSecurity('apiKey') @UseInterceptors(LoggingInterceptor) @Controller(COLLECTION_STORE) @ApiTags(COLLECTION_STORE)