allow methods
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
export const DB_NAME = '/store-service';
|
export const DB_NAME = '/store-service';
|
||||||
export const MONGO_URL = `mongodb://localhost:27017${DB_NAME}`;
|
export const MONGO_URL = `mongodb://localhost:27017${DB_NAME}`;
|
||||||
export const ALLOW_ORIGIN_ALL: [string, string] = ['Access-Control-Allow-Origin', '*'];
|
export const ALLOW_ORIGIN_ALL: [string, string] = ['Access-Control-Allow-Origin', '*'];
|
||||||
|
export const ALLOW_METHOD: [string, string] = ['Access-Control-Request-Method', 'POST DELETE PUT GET'];
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Controller, Get, Post, Body, Param, Header, Delete } from '@nestjs/comm
|
|||||||
import {StoreService} from './store.service';
|
import {StoreService} from './store.service';
|
||||||
import {Store, StoreResponse, StoreRequest} from './store.schema';
|
import {Store, StoreResponse, StoreRequest} from './store.schema';
|
||||||
import {ApiResponse} from '@nestjs/swagger';
|
import {ApiResponse} from '@nestjs/swagger';
|
||||||
import {ALLOW_ORIGIN_ALL} from 'src/consts';
|
import {ALLOW_ORIGIN_ALL, ALLOW_METHOD} from 'src/consts';
|
||||||
|
|
||||||
@Controller('store')
|
@Controller('store')
|
||||||
export class StoreController {
|
export class StoreController {
|
||||||
@ -12,6 +12,7 @@ export class StoreController {
|
|||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@Header(...ALLOW_ORIGIN_ALL)
|
@Header(...ALLOW_ORIGIN_ALL)
|
||||||
|
@Header(...ALLOW_METHOD)
|
||||||
@ApiResponse({
|
@ApiResponse({
|
||||||
status: 200,
|
status: 200,
|
||||||
description: 'Список всех пар ключ-значение',
|
description: 'Список всех пар ключ-значение',
|
||||||
@ -23,6 +24,7 @@ export class StoreController {
|
|||||||
|
|
||||||
@Get(':key')
|
@Get(':key')
|
||||||
@Header(...ALLOW_ORIGIN_ALL)
|
@Header(...ALLOW_ORIGIN_ALL)
|
||||||
|
@Header(...ALLOW_METHOD)
|
||||||
@ApiResponse({
|
@ApiResponse({
|
||||||
status: 200,
|
status: 200,
|
||||||
description: 'Возвращает пару ключ-значение по ключу',
|
description: 'Возвращает пару ключ-значение по ключу',
|
||||||
@ -34,6 +36,7 @@ export class StoreController {
|
|||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
@Header(...ALLOW_ORIGIN_ALL)
|
@Header(...ALLOW_ORIGIN_ALL)
|
||||||
|
@Header(...ALLOW_METHOD)
|
||||||
@ApiResponse({
|
@ApiResponse({
|
||||||
status: 200,
|
status: 200,
|
||||||
description: 'Создает новую пару ключ-значение или заменяет существующую по ключу',
|
description: 'Создает новую пару ключ-значение или заменяет существующую по ключу',
|
||||||
@ -45,6 +48,7 @@ export class StoreController {
|
|||||||
|
|
||||||
@Delete(':key')
|
@Delete(':key')
|
||||||
@Header(...ALLOW_ORIGIN_ALL)
|
@Header(...ALLOW_ORIGIN_ALL)
|
||||||
|
@Header(...ALLOW_METHOD)
|
||||||
@ApiResponse({
|
@ApiResponse({
|
||||||
status: 200,
|
status: 200,
|
||||||
description: 'Удаляет пару ключ-значение по ключу',
|
description: 'Удаляет пару ключ-значение по ключу',
|
||||||
|
|||||||
Reference in New Issue
Block a user