mirror of
https://github.com/Kevsl/crypto-exchange-api.git
synced 2025-07-12 14:50:13 +02:00
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Get,
|
|
HttpCode,
|
|
HttpStatus,
|
|
Param,
|
|
Patch,
|
|
Post,
|
|
UseGuards,
|
|
// UseGuards,
|
|
} from '@nestjs/common';
|
|
import { GetUser } from '../auth/decorator';
|
|
// import { JwtGuard } from '../auth/guard';
|
|
import { ApiTags } from '@nestjs/swagger';
|
|
import { User } from '@prisma/client';
|
|
import { JwtGuard } from 'src/auth/guard';
|
|
import { OfferService } from './offer.service';
|
|
import { OfferDto } from './dto';
|
|
|
|
@UseGuards(JwtGuard)
|
|
@ApiTags('offer')
|
|
@Controller('offer')
|
|
export class OfferController {
|
|
constructor(private offerService: OfferService) {}
|
|
|
|
@Get('/all')
|
|
getAllOffers(@GetUser() user: User) {
|
|
return this.offerService.getOffers(user.id);
|
|
}
|
|
@Get('/search/:id')
|
|
searchOfferByCryptoId(@GetUser() user: User, @Param('id') cryptoId: string) {
|
|
return this.offerService.getOffersByCryptoId(user.id, cryptoId);
|
|
}
|
|
|
|
@HttpCode(HttpStatus.CREATED)
|
|
@Post('/create')
|
|
createRole(
|
|
@Body()
|
|
dto: OfferDto,
|
|
@GetUser() user: User,
|
|
) {
|
|
return this.offerService.createOffer(user.id, dto);
|
|
}
|
|
|
|
@HttpCode(HttpStatus.OK)
|
|
@Patch('/update/:id')
|
|
editOfferById(
|
|
@Param('id') offerId: string,
|
|
@Body() dto: OfferDto,
|
|
@GetUser() user: User,
|
|
) {
|
|
return this.offerService.editOfferById(user.id, offerId, dto);
|
|
}
|
|
|
|
@HttpCode(HttpStatus.NO_CONTENT)
|
|
@Delete('/delete/:id')
|
|
deleteOfferById(@Param('id') roleId: string, @GetUser() user: User) {
|
|
return this.offerService.deleteOfferById(user.id, roleId);
|
|
}
|
|
}
|