access options
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
import { Controller, Get, Post, Body, Param, Header, Delete } from '@nestjs/common';
|
||||
import { Controller, Get, Post, Body, Param, Options, Header, Delete, HttpCode } from '@nestjs/common';
|
||||
import {StoreService} from './store.service';
|
||||
import {Store, StoreResponse, StoreRequest} from './store.schema';
|
||||
import {ApiResponse} from '@nestjs/swagger';
|
||||
import {ALLOW_ORIGIN_ALL, ALLOW_METHOD, ALLOW_CREDENTIALS} from 'src/consts';
|
||||
import {ALLOW_ORIGIN_ALL, ALLOW_METHOD, ALLOW_CREDENTIALS, CONTENT_LENGTH, ALLOW_HEADERS} from 'src/consts';
|
||||
|
||||
@Controller('store')
|
||||
export class StoreController {
|
||||
@ -12,8 +12,6 @@ export class StoreController {
|
||||
|
||||
@Get()
|
||||
@Header(...ALLOW_ORIGIN_ALL)
|
||||
@Header(...ALLOW_METHOD)
|
||||
@Header(...ALLOW_CREDENTIALS)
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Список всех пар ключ-значение',
|
||||
@ -25,8 +23,6 @@ export class StoreController {
|
||||
|
||||
@Get(':key')
|
||||
@Header(...ALLOW_ORIGIN_ALL)
|
||||
@Header(...ALLOW_METHOD)
|
||||
@Header(...ALLOW_CREDENTIALS)
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Возвращает пару ключ-значение по ключу',
|
||||
@ -38,8 +34,6 @@ export class StoreController {
|
||||
|
||||
@Post()
|
||||
@Header(...ALLOW_ORIGIN_ALL)
|
||||
@Header(...ALLOW_METHOD)
|
||||
@Header(...ALLOW_CREDENTIALS)
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Создает новую пару ключ-значение или заменяет существующую по ключу',
|
||||
@ -51,8 +45,6 @@ export class StoreController {
|
||||
|
||||
@Delete(':key')
|
||||
@Header(...ALLOW_ORIGIN_ALL)
|
||||
@Header(...ALLOW_METHOD)
|
||||
@Header(...ALLOW_CREDENTIALS)
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Удаляет пару ключ-значение по ключу',
|
||||
@ -61,4 +53,15 @@ export class StoreController {
|
||||
async removeOne(@Param() {key}: {key: string}): Promise<string> {
|
||||
return this.storeService.removeOne(key);
|
||||
}
|
||||
|
||||
@Options()
|
||||
@Header(...ALLOW_ORIGIN_ALL)
|
||||
@Header(...ALLOW_METHOD)
|
||||
@Header(...ALLOW_CREDENTIALS)
|
||||
@Header(...CONTENT_LENGTH)
|
||||
@Header(...ALLOW_HEADERS)
|
||||
@HttpCode(204)
|
||||
async options() {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user