chore: strengthen backend eslint profile
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import type { Request } from 'express';
|
||||
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
@@ -21,12 +23,16 @@ import {
|
||||
ApiTags,
|
||||
getSchemaPath,
|
||||
} from '@nestjs/swagger';
|
||||
import type { Request } from 'express';
|
||||
|
||||
import {
|
||||
ApiProblemResponses,
|
||||
ProblemDetailsDto,
|
||||
} from '../../../../common/decorators/api-safe-error-response.decorator';
|
||||
import { AccessPayload, JwtAuthGuard } from '../../../auth/auth.api';
|
||||
import { BankCardsService } from '../application/bank-cards.service';
|
||||
import { BankOperationsService } from '../application/bank-operations.service';
|
||||
import { ExpenseCategoriesService } from '../application/expense-categories.service';
|
||||
import { GetBankSummaryUseCase } from '../application/get-bank-summary.use-case';
|
||||
import {
|
||||
BankCardDto,
|
||||
BankCardsQueryDto,
|
||||
@@ -45,10 +51,6 @@ import {
|
||||
UpdateBankOperationDto,
|
||||
UpdateExpenseCategoryDto,
|
||||
} from './bank-card.dto';
|
||||
import { BankCardsService } from '../application/bank-cards.service';
|
||||
import { BankOperationsService } from '../application/bank-operations.service';
|
||||
import { ExpenseCategoriesService } from '../application/expense-categories.service';
|
||||
import { GetBankSummaryUseCase } from '../application/get-bank-summary.use-case';
|
||||
type AuthRequest = Request & { user: AccessPayload };
|
||||
@ApiResponse({
|
||||
status: 409,
|
||||
@@ -82,26 +84,31 @@ export class BankCardsController {
|
||||
private readonly expenseCategories: ExpenseCategoriesService,
|
||||
private readonly bankSummary: GetBankSummaryUseCase,
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
@ApiOkResponse({ type: BankCardDto, isArray: true })
|
||||
list(@Req() req: AuthRequest, @Query() query: BankCardsQueryDto) {
|
||||
return this.cards.list(req.user.sub, query.includeArchived === 'true');
|
||||
}
|
||||
|
||||
@Post()
|
||||
@ApiCreatedResponse({ type: BankCardDto })
|
||||
create(@Req() req: AuthRequest, @Body() body: CreateBankCardDto) {
|
||||
return this.cards.createCard(req.user.sub, body);
|
||||
}
|
||||
|
||||
@Get('categories')
|
||||
@ApiOkResponse({ type: ExpenseCategoryDto, isArray: true })
|
||||
categories(@Req() req: AuthRequest) {
|
||||
return this.expenseCategories.categories(req.user.sub);
|
||||
}
|
||||
|
||||
@Post('categories')
|
||||
@ApiCreatedResponse({ type: ExpenseCategoryDto })
|
||||
createCategory(@Req() req: AuthRequest, @Body() body: CategoryNameDto) {
|
||||
return this.expenseCategories.createCategory(req.user.sub, body.name);
|
||||
}
|
||||
|
||||
@Patch('categories/:id')
|
||||
@ApiOkResponse({ type: ExpenseCategoryDto })
|
||||
updateCategory(
|
||||
@@ -116,11 +123,13 @@ export class BankCardsController {
|
||||
body.version,
|
||||
);
|
||||
}
|
||||
|
||||
@Get('summary')
|
||||
@ApiOkResponse({ type: BankSummaryDto })
|
||||
summary(@Req() req: AuthRequest, @Query() query: BankSummaryQueryDto) {
|
||||
return this.bankSummary.execute(req.user.sub, query);
|
||||
}
|
||||
|
||||
@Post('operations')
|
||||
@ApiCreatedResponse({ type: BankOperationDto })
|
||||
createOperation(
|
||||
@@ -129,11 +138,13 @@ export class BankCardsController {
|
||||
) {
|
||||
return this.operations.createOperation(req.user.sub, body);
|
||||
}
|
||||
|
||||
@Get('operations/:id')
|
||||
@ApiOkResponse({ type: BankOperationDto })
|
||||
operation(@Req() req: AuthRequest, @Param('id') id: string) {
|
||||
return this.operations.getOperation(req.user.sub, id);
|
||||
}
|
||||
|
||||
@Patch('operations/:id')
|
||||
@ApiOkResponse({ type: BankOperationDto })
|
||||
updateOperation(
|
||||
@@ -143,6 +154,7 @@ export class BankCardsController {
|
||||
) {
|
||||
return this.operations.updateOperation(req.user.sub, id, body);
|
||||
}
|
||||
|
||||
@Delete('operations/:id')
|
||||
@HttpCode(HttpStatus.NO_CONTENT)
|
||||
@ApiNoContentResponse()
|
||||
@@ -153,6 +165,7 @@ export class BankCardsController {
|
||||
) {
|
||||
return this.operations.deleteOperation(req.user.sub, id, query.version);
|
||||
}
|
||||
|
||||
@Get(':id/operations')
|
||||
@ApiOkResponse({ type: BankOperationsPageDto })
|
||||
history(
|
||||
@@ -162,6 +175,7 @@ export class BankCardsController {
|
||||
) {
|
||||
return this.operations.history(req.user.sub, id, query);
|
||||
}
|
||||
|
||||
@Get(':id/expenses')
|
||||
@ApiOkResponse({ type: BankOperationsPageDto })
|
||||
expenses(
|
||||
@@ -171,11 +185,13 @@ export class BankCardsController {
|
||||
) {
|
||||
return this.operations.history(req.user.sub, id, query, true);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOkResponse({ type: BankCardDto })
|
||||
get(@Req() req: AuthRequest, @Param('id') id: string) {
|
||||
return this.cards.get(req.user.sub, id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@ApiOkResponse({ type: BankCardDto })
|
||||
update(
|
||||
|
||||
Reference in New Issue
Block a user