feat: add tbank tokens
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
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 {
|
||||
PutTbankConnectionDto,
|
||||
TbankConnectionStatusDto,
|
||||
} from './tbank-connection.dto';
|
||||
import { TbankConnectionService } from './tbank-connection.service';
|
||||
|
||||
@ApiTags('tbank-connection')
|
||||
@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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user