mirror of
https://git.meshkee.com/Meshkee/backend.git
synced 2026-08-12 06:40:58 +04:30
Initial commit: Meshkee CMS API
NestJS backend with Prisma, Docker Compose for Postgres/Redis, and deploy docs for the production VM.
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { AuthUser } from '../auth/auth.types';
|
||||
import { CurrentUser } from '../auth/decorators/current-user.decorator';
|
||||
import { RequireBusinessPermission } from '../auth/decorators/require-business-permission.decorator';
|
||||
import { BusinessPermissionGuard } from '../auth/guards/business-permission.guard';
|
||||
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
||||
import {
|
||||
AddCartItemDto,
|
||||
CheckoutCartDto,
|
||||
UpdateCartItemDto,
|
||||
} from './dto/cart.dto';
|
||||
import { CartService } from './cart.service';
|
||||
|
||||
@Controller('businesses/:businessId/cart')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class CartController {
|
||||
constructor(private readonly service: CartService) {}
|
||||
|
||||
@Get()
|
||||
getCart(@Param('businessId') businessId: string, @CurrentUser() user: AuthUser) {
|
||||
return this.service.getCart(businessId, user);
|
||||
}
|
||||
|
||||
@Post('items')
|
||||
addItem(
|
||||
@Param('businessId') businessId: string,
|
||||
@Body() dto: AddCartItemDto,
|
||||
@CurrentUser() user: AuthUser,
|
||||
) {
|
||||
return this.service.addItem(businessId, dto, user);
|
||||
}
|
||||
|
||||
@Patch('items/:itemId')
|
||||
updateItem(
|
||||
@Param('businessId') businessId: string,
|
||||
@Param('itemId') itemId: string,
|
||||
@Body() dto: UpdateCartItemDto,
|
||||
@CurrentUser() user: AuthUser,
|
||||
) {
|
||||
return this.service.updateItem(businessId, itemId, dto, user);
|
||||
}
|
||||
|
||||
@Delete('items/:itemId')
|
||||
removeItem(
|
||||
@Param('businessId') businessId: string,
|
||||
@Param('itemId') itemId: string,
|
||||
@CurrentUser() user: AuthUser,
|
||||
) {
|
||||
return this.service.removeItem(businessId, itemId, user);
|
||||
}
|
||||
|
||||
@Delete()
|
||||
clear(@Param('businessId') businessId: string, @CurrentUser() user: AuthUser) {
|
||||
return this.service.clear(businessId, user);
|
||||
}
|
||||
|
||||
@Post('checkout')
|
||||
checkout(
|
||||
@Param('businessId') businessId: string,
|
||||
@Body() dto: CheckoutCartDto,
|
||||
@CurrentUser() user: AuthUser,
|
||||
) {
|
||||
return this.service.checkout(businessId, dto, user);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user