first commit

This commit is contained in:
2025-11-06 16:40:32 +03:00
commit f0948a5b05
51 changed files with 13047 additions and 0 deletions
+69
View File
@@ -0,0 +1,69 @@
import {
Body,
Controller,
Delete,
Get,
Param,
Post,
Put,
Request,
UseGuards,
} from '@nestjs/common';
import { RestaurantService } from './restaurant.service';
import { CreateRestaurantDto } from './dto/create-restaurant.dto';
import { UpdateRestaurantDto } from './dto/update-restaurant.dto';
import { AuthGuard, Session } from '@thallesp/nestjs-better-auth';
import type { UserSession } from '@thallesp/nestjs-better-auth';
@Controller('restaurants')
export class RestaurantController {
constructor(private readonly service: RestaurantService) {}
@UseGuards(AuthGuard)
@Post()
async create(
@Body() dto: CreateRestaurantDto,
@Session() session: UserSession,
) {
const ownerId = session.user.id;
return await this.service.create(ownerId, dto);
}
@UseGuards(AuthGuard)
@Get('my')
async myRestaurants(@Session() session) {
return await this.service.findByOwner(session.user.id);
}
@Get()
async findAll() {
return await this.service.findAll();
}
@Get(':id')
async findOne(@Param('id') id: string) {
return await this.service.findOne(id);
}
@UseGuards(AuthGuard)
@Put(':id')
async update(
@Param('id') id: string,
@Body() dto: UpdateRestaurantDto,
@Session() session: UserSession,
) {
return await this.service.update(id, dto, session.user.id);
}
@UseGuards(AuthGuard)
@Delete(':id')
async remove(@Param('id') id: string, @Session() session: UserSession) {
await this.service.remove(id, session.user.id);
}
// public menu by slug
@Get('/public/:slug')
async publicBySlug(@Param('slug') slug: string) {
return await this.service.findBySlug(slug);
}
}