on auth token
This commit is contained in:
@ -18,6 +18,7 @@ import {
|
||||
REMOVE_SUCCESS,
|
||||
REMOVE_NOT_FOUND,
|
||||
} from './store.responses';
|
||||
import {AuthService} from 'src/services/auth.service';
|
||||
|
||||
const prepareStoreToStoreRequest = ({
|
||||
key, value, description, service_name, author
|
||||
@ -35,13 +36,17 @@ const makeApiHeader = (request: Request): string => {
|
||||
@ApiTags(COLLECTION_STORE)
|
||||
export class StoreController {
|
||||
constructor(
|
||||
private readonly storeService: StoreService
|
||||
private readonly storeService: StoreService,
|
||||
private readonly authService: AuthService,
|
||||
) {}
|
||||
|
||||
|
||||
@Get()
|
||||
@Header(...ALLOW_ORIGIN_ALL)
|
||||
@ApiResponse(FIND_ALL_SUCCESS)
|
||||
async findAll(@Req() request: Request): Promise<StoreRequest[]> {
|
||||
await this.authService.checkRequest(request);
|
||||
|
||||
const api = makeApiHeader(request);
|
||||
const storeList = await this.storeService.findAll(api);
|
||||
return storeList.map(prepareStoreToStoreRequest);
|
||||
@ -56,6 +61,8 @@ export class StoreController {
|
||||
description: 'Ключ для поиска хранилища',
|
||||
})
|
||||
async findOne(@Req() request: Request<{key: string}>): Promise<StoreRequest> {
|
||||
await this.authService.checkRequest(request);
|
||||
|
||||
const {key} = request.params;
|
||||
const api = makeApiHeader(request);
|
||||
const store = await this.storeService.findOne(api, key);
|
||||
|
||||
Reference in New Issue
Block a user