Spaces:
Sleeping
Sleeping
Download src/orders/orders.controller.ts from IlyasDaoud/omnia-eats-api: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/spaces/IlyasDaoud/omnia-eats-api/resolve/main/src/orders/orders.controller.ts
- Command line
-
hf download hf://spaces/IlyasDaoud/omnia-eats-api/src/orders/orders.controller.ts
-
curl -L -o orders.controller.ts https://huggingface.co/spaces/IlyasDaoud/omnia-eats-api/resolve/main/src/orders/orders.controller.ts
1.24 kB
| import { Body, Controller, Get, Param, Patch, Post, UseGuards } from '@nestjs/common'; | |
| import { Type } from 'class-transformer'; | |
| import { IsArray, IsIn, IsInt, IsOptional, IsString, Min, ValidateNested } from 'class-validator'; | |
| import type { User } from '@prisma/client'; | |
| import { OrdersService } from './orders.service'; | |
| import { AuthGuard } from '../auth/auth.guard'; | |
| import { CurrentUser } from '../auth/current-user.decorator'; | |
| class OrderItemDto { | |
| () menuItemId!: string; | |
| (() => Number) () (1) qty = 1; | |
| } | |
| class CreateOrderDto { | |
| () vendorId!: string; | |
| () ({ each: true }) (() => OrderItemDto) items!: OrderItemDto[]; | |
| () (['web', 'agent']) source?: 'web' | 'agent'; | |
| } | |
| ('orders') | |
| (AuthGuard) | |
| export class OrdersController { | |
| constructor(private readonly orders: OrdersService) {} | |
| () | |
| create(() user: User, () dto: CreateOrderDto) { | |
| return this.orders.create(user, dto); | |
| } | |
| () | |
| listMine(() user: User) { | |
| return this.orders.listMine(user); | |
| } | |
| (':id/cancel') | |
| cancel(() user: User, ('id') id: string) { | |
| return this.orders.cancel(user, id); | |
| } | |
| } | |