credentials header
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
export const DB_NAME = '/store-service';
|
||||
export const MONGO_URL = `mongodb://localhost:27017${DB_NAME}`;
|
||||
export const ALLOW_ORIGIN_ALL: [string, string] = ['Access-Control-Allow-Origin', '*'];
|
||||
export const ALLOW_CREDENTIALS: [string, string] = ['Access-Control-Allow-Credentials', 'true'];
|
||||
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 {Store, StoreResponse, StoreRequest} from './store.schema';
|
||||
import {ApiResponse} from '@nestjs/swagger';
|
||||
import {ALLOW_ORIGIN_ALL, ALLOW_METHOD} from 'src/consts';
|
||||
import {ALLOW_ORIGIN_ALL, ALLOW_METHOD, ALLOW_CREDENTIALS} from 'src/consts';
|
||||
|
||||
@Controller('store')
|
||||
export class StoreController {
|
||||
@ -13,6 +13,7 @@ export class StoreController {
|
||||
@Get()
|
||||
@Header(...ALLOW_ORIGIN_ALL)
|
||||
@Header(...ALLOW_METHOD)
|
||||
@Header(...ALLOW_CREDENTIALS)
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Список всех пар ключ-значение',
|
||||
@ -25,6 +26,7 @@ export class StoreController {
|
||||
@Get(':key')
|
||||
@Header(...ALLOW_ORIGIN_ALL)
|
||||
@Header(...ALLOW_METHOD)
|
||||
@Header(...ALLOW_CREDENTIALS)
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Возвращает пару ключ-значение по ключу',
|
||||
@ -37,6 +39,7 @@ export class StoreController {
|
||||
@Post()
|
||||
@Header(...ALLOW_ORIGIN_ALL)
|
||||
@Header(...ALLOW_METHOD)
|
||||
@Header(...ALLOW_CREDENTIALS)
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Создает новую пару ключ-значение или заменяет существующую по ключу',
|
||||
@ -49,6 +52,7 @@ export class StoreController {
|
||||
@Delete(':key')
|
||||
@Header(...ALLOW_ORIGIN_ALL)
|
||||
@Header(...ALLOW_METHOD)
|
||||
@Header(...ALLOW_CREDENTIALS)
|
||||
@ApiResponse({
|
||||
status: 200,
|
||||
description: 'Удаляет пару ключ-значение по ключу',
|
||||
|
||||
@ -6,7 +6,7 @@ GET http://localhost:4001/store/testApi HTTP/1.1
|
||||
|
||||
###
|
||||
|
||||
POST http://localhost:4001/store HTTP/1.1
|
||||
POST http://vigdorov.ru:4001/store HTTP/1.1
|
||||
content-type: application/json
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user