57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
HttpCode,
|
|
Put,
|
|
Req,
|
|
UseGuards,
|
|
} from '@nestjs/common';
|
|
import {
|
|
ApiBearerAuth,
|
|
ApiNoContentResponse,
|
|
ApiOkResponse,
|
|
ApiTags,
|
|
} from '@nestjs/swagger';
|
|
import type { Request } from 'express';
|
|
import { AccessPayload } from '../auth/auth.types';
|
|
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
|
import { ApiProblemResponses } from '../common/decorators/api-safe-error-response.decorator';
|
|
import {
|
|
PutTbankConnectionDto,
|
|
TbankConnectionStatusDto,
|
|
} from './tbank-connection.dto';
|
|
import { TbankConnectionService } from './tbank-connection.service';
|
|
|
|
@ApiTags('tbank-connection')
|
|
@ApiProblemResponses()
|
|
@ApiBearerAuth()
|
|
@UseGuards(JwtAuthGuard)
|
|
@Controller('tbank-connection')
|
|
export class TbankConnectionController {
|
|
constructor(private readonly connection: TbankConnectionService) {}
|
|
|
|
@Get()
|
|
@ApiOkResponse({ type: TbankConnectionStatusDto })
|
|
status(@Req() request: Request & { user: AccessPayload }) {
|
|
return this.connection.status(request.user.sub);
|
|
}
|
|
|
|
@Put()
|
|
@ApiOkResponse({ type: TbankConnectionStatusDto })
|
|
put(
|
|
@Req() request: Request & { user: AccessPayload },
|
|
@Body() body: PutTbankConnectionDto,
|
|
) {
|
|
return this.connection.put(request.user.sub, body.token);
|
|
}
|
|
|
|
@Delete()
|
|
@HttpCode(204)
|
|
@ApiNoContentResponse()
|
|
delete(@Req() request: Request & { user: AccessPayload }): Promise<void> {
|
|
return this.connection.delete(request.user.sub);
|
|
}
|
|
}
|