clean
This commit is contained in:
@@ -1,15 +0,0 @@
|
|||||||
import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common';
|
|
||||||
import { map, Observable } from 'rxjs';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ResponseInterceptor<T> implements NestInterceptor<T, any> {
|
|
||||||
intercept(context: ExecutionContext, next: CallHandler<T>): Observable<any> {
|
|
||||||
return next.handle().pipe(
|
|
||||||
map(data => ({
|
|
||||||
success: true,
|
|
||||||
data,
|
|
||||||
timestamp: new Date().toISOString(),
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
import { Injectable, Logger, NestMiddleware } from "@nestjs/common";
|
import { Injectable, Logger, NestMiddleware } from '@nestjs/common';
|
||||||
import { FastifyReply, FastifyRequest } from "fastify";
|
import { FastifyReply, FastifyRequest } from 'fastify';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class HTTPLogger implements NestMiddleware {
|
export class HTTPLogger implements NestMiddleware {
|
||||||
private readonly logger = new Logger(HTTPLogger.name);
|
private readonly logger = new Logger(HTTPLogger.name);
|
||||||
// use(req: any, res: any, next: (error?: Error | any) => void) {}
|
// use(req: any, res: any, next: (error?: Error | any) => void) {}
|
||||||
|
|
||||||
use(req: FastifyRequest, rep: FastifyReply["raw"], next: () => void) {
|
use(req: FastifyRequest, rep: FastifyReply['raw'], next: () => void) {
|
||||||
const { ip, method, originalUrl } = req;
|
const { ip, method, originalUrl } = req;
|
||||||
const userAgent = req.headers["user-agent"] || "";
|
const userAgent = req.headers['user-agent'] || '';
|
||||||
const startAt = process.hrtime();
|
const startAt = process.hrtime();
|
||||||
|
|
||||||
rep.on("finish", () => {
|
rep.on('finish', () => {
|
||||||
const { statusCode } = rep;
|
const { statusCode } = rep;
|
||||||
const contentLength = rep.getHeader("content-length") || 0;
|
const contentLength = rep.getHeader('content-length') || 0;
|
||||||
const dif = process.hrtime(startAt);
|
const dif = process.hrtime(startAt);
|
||||||
const responseTime = dif[0] * 1e3 + dif[1] * 1e-6;
|
const responseTime = dif[0] * 1e3 + dif[1] * 1e-6;
|
||||||
this.logger.log(
|
this.logger.log(
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Controller, Post, Body, HttpCode, HttpStatus, Get, UseGuards, Patch, Pa
|
|||||||
import { AdminService } from '../providers/admin.service';
|
import { AdminService } from '../providers/admin.service';
|
||||||
import { CreateAdminDto } from '../dto/create-admin.dto';
|
import { CreateAdminDto } from '../dto/create-admin.dto';
|
||||||
import { UpdateAdminDto } from '../dto/update-admin.dto';
|
import { UpdateAdminDto } from '../dto/update-admin.dto';
|
||||||
import { ApiTags, ApiOperation, ApiBody, ApiResponse, ApiBearerAuth, ApiParam } from '@nestjs/swagger';
|
import { ApiTags, ApiOperation, ApiBody, ApiBearerAuth, ApiParam } from '@nestjs/swagger';
|
||||||
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
|
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
|
||||||
import { RestId } from 'src/common/decorators';
|
import { RestId } from 'src/common/decorators';
|
||||||
import { AdminId } from 'src/common/decorators/admin-id.decorator';
|
import { AdminId } from 'src/common/decorators/admin-id.decorator';
|
||||||
@@ -17,7 +17,6 @@ export class AdminController {
|
|||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@ApiOperation({ summary: 'admin' })
|
@ApiOperation({ summary: 'admin' })
|
||||||
@ApiResponse({ status: 201, description: 'Admins' })
|
|
||||||
async getAll(@RestId() restId: string) {
|
async getAll(@RestId() restId: string) {
|
||||||
const admin = await this.adminService.findAllByRestaurantId(restId);
|
const admin = await this.adminService.findAllByRestaurantId(restId);
|
||||||
return admin;
|
return admin;
|
||||||
@@ -25,7 +24,6 @@ export class AdminController {
|
|||||||
|
|
||||||
@Get('profile')
|
@Get('profile')
|
||||||
@ApiOperation({ summary: 'admin' })
|
@ApiOperation({ summary: 'admin' })
|
||||||
@ApiResponse({ status: 201, description: 'Admins' })
|
|
||||||
async getMe(@AdminId() adminId: string, @RestId() restId: string) {
|
async getMe(@AdminId() adminId: string, @RestId() restId: string) {
|
||||||
const admin = await this.adminService.findById(adminId, restId);
|
const admin = await this.adminService.findById(adminId, restId);
|
||||||
return admin;
|
return admin;
|
||||||
@@ -35,7 +33,6 @@ export class AdminController {
|
|||||||
@HttpCode(HttpStatus.CREATED)
|
@HttpCode(HttpStatus.CREATED)
|
||||||
@ApiOperation({ summary: 'Create a new admin' })
|
@ApiOperation({ summary: 'Create a new admin' })
|
||||||
@ApiBody({ type: CreateAdminDto })
|
@ApiBody({ type: CreateAdminDto })
|
||||||
@ApiResponse({ status: 201, description: 'Admin created' })
|
|
||||||
async create(@Body() dto: CreateAdminDto, @RestId() restId: string) {
|
async create(@Body() dto: CreateAdminDto, @RestId() restId: string) {
|
||||||
const admin = await this.adminService.createAdminForMyRestaurant(restId, dto);
|
const admin = await this.adminService.createAdminForMyRestaurant(restId, dto);
|
||||||
return admin;
|
return admin;
|
||||||
@@ -45,24 +42,18 @@ export class AdminController {
|
|||||||
@ApiOperation({ summary: 'Update an admin' })
|
@ApiOperation({ summary: 'Update an admin' })
|
||||||
@ApiParam({ name: 'adminId', description: 'Admin ID' })
|
@ApiParam({ name: 'adminId', description: 'Admin ID' })
|
||||||
@ApiBody({ type: UpdateAdminDto })
|
@ApiBody({ type: UpdateAdminDto })
|
||||||
@ApiResponse({ status: 200, description: 'Admin updated successfully' })
|
|
||||||
@ApiResponse({ status: 404, description: 'Admin not found' })
|
|
||||||
update(@Param('adminId') adminId: string, @Body() dto: UpdateAdminDto, @RestId() restId: string): Promise<Admin> {
|
update(@Param('adminId') adminId: string, @Body() dto: UpdateAdminDto, @RestId() restId: string): Promise<Admin> {
|
||||||
return this.adminService.update(adminId, restId, dto);
|
return this.adminService.update(adminId, restId, dto);
|
||||||
}
|
}
|
||||||
@Get(':adminId')
|
@Get(':adminId')
|
||||||
@ApiOperation({ summary: 'Get an admin by ID' })
|
@ApiOperation({ summary: 'Get an admin by ID' })
|
||||||
@ApiParam({ name: 'id', description: 'Admin ID' })
|
@ApiParam({ name: 'id', description: 'Admin ID' })
|
||||||
@ApiResponse({ status: 200, description: 'Admin found successfully' })
|
|
||||||
@ApiResponse({ status: 404, description: 'Admin not found' })
|
|
||||||
getById(@Param('adminId') adminId: string, @RestId() restId: string): Promise<Admin | null> {
|
getById(@Param('adminId') adminId: string, @RestId() restId: string): Promise<Admin | null> {
|
||||||
return this.adminService.findById(adminId, restId);
|
return this.adminService.findById(adminId, restId);
|
||||||
}
|
}
|
||||||
@Delete(':adminId')
|
@Delete(':adminId')
|
||||||
@ApiOperation({ summary: 'Delete an admin by ID' })
|
@ApiOperation({ summary: 'Delete an admin by ID' })
|
||||||
@ApiParam({ name: 'id', description: 'Admin ID' })
|
@ApiParam({ name: 'id', description: 'Admin ID' })
|
||||||
@ApiResponse({ status: 200, description: 'Admin deleted successfully' })
|
|
||||||
@ApiResponse({ status: 404, description: 'Admin not found' })
|
|
||||||
deleteById(@Param('adminId') adminId: string, @RestId() restId: string): Promise<void> {
|
deleteById(@Param('adminId') adminId: string, @RestId() restId: string): Promise<void> {
|
||||||
return this.adminService.remove(adminId, restId);
|
return this.adminService.remove(adminId, restId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Controller, Post, Body } from '@nestjs/common';
|
import { Controller, Post, Body } from '@nestjs/common';
|
||||||
import { AuthService } from '../services/auth.service';
|
import { AuthService } from '../services/auth.service';
|
||||||
import { RequestOtpDto } from '../dto/request-otp.dto';
|
import { RequestOtpDto } from '../dto/request-otp.dto';
|
||||||
import { ApiTags, ApiOperation, ApiBody, ApiResponse } from '@nestjs/swagger';
|
import { ApiTags, ApiOperation, ApiBody } from '@nestjs/swagger';
|
||||||
import { VerifyOtpDto } from '../dto/verify-otp.dto';
|
import { VerifyOtpDto } from '../dto/verify-otp.dto';
|
||||||
import { Throttle } from '@nestjs/throttler';
|
import { Throttle } from '@nestjs/throttler';
|
||||||
import { RefreshTokenRateLimit } from 'src/common/decorators/rate-limit.decorator';
|
import { RefreshTokenRateLimit } from 'src/common/decorators/rate-limit.decorator';
|
||||||
@@ -16,8 +16,6 @@ export class AuthController {
|
|||||||
@Post('public/auth/otp/request')
|
@Post('public/auth/otp/request')
|
||||||
@ApiOperation({ summary: 'Request OTP for login or signup' })
|
@ApiOperation({ summary: 'Request OTP for login or signup' })
|
||||||
@ApiBody({ type: RequestOtpDto, description: 'Mobile number to receive OTP' })
|
@ApiBody({ type: RequestOtpDto, description: 'Mobile number to receive OTP' })
|
||||||
@ApiResponse({ status: 201, description: 'OTP requested successfully' })
|
|
||||||
@ApiResponse({ status: 400, description: 'Invalid mobile number' })
|
|
||||||
otpRequest(@Body() dto: RequestOtpDto) {
|
otpRequest(@Body() dto: RequestOtpDto) {
|
||||||
return this.authService.requestOtp(dto, false);
|
return this.authService.requestOtp(dto, false);
|
||||||
}
|
}
|
||||||
@@ -25,8 +23,6 @@ export class AuthController {
|
|||||||
@Post('public/auth/otp/verify')
|
@Post('public/auth/otp/verify')
|
||||||
@ApiOperation({ summary: 'Verify OTP code' })
|
@ApiOperation({ summary: 'Verify OTP code' })
|
||||||
@ApiBody({ type: VerifyOtpDto, description: 'Mobile number and OTP code' })
|
@ApiBody({ type: VerifyOtpDto, description: 'Mobile number and OTP code' })
|
||||||
@ApiResponse({ status: 200, description: 'OTP verified successfully' })
|
|
||||||
@ApiResponse({ status: 400, description: 'Invalid OTP or expired' })
|
|
||||||
otpVerify(@Body() dto: VerifyOtpDto) {
|
otpVerify(@Body() dto: VerifyOtpDto) {
|
||||||
return this.authService.verifyOtp(dto.phone, dto.slug, dto.otp); // assuming dto has `otp` property
|
return this.authService.verifyOtp(dto.phone, dto.slug, dto.otp); // assuming dto has `otp` property
|
||||||
}
|
}
|
||||||
@@ -42,8 +38,6 @@ export class AuthController {
|
|||||||
@Post('admin/auth/otp/request')
|
@Post('admin/auth/otp/request')
|
||||||
@ApiOperation({ summary: 'Request OTP for login or signup' })
|
@ApiOperation({ summary: 'Request OTP for login or signup' })
|
||||||
@ApiBody({ type: RequestOtpDto, description: 'Mobile number to receive OTP' })
|
@ApiBody({ type: RequestOtpDto, description: 'Mobile number to receive OTP' })
|
||||||
@ApiResponse({ status: 201, description: 'OTP requested successfully' })
|
|
||||||
@ApiResponse({ status: 400, description: 'Invalid mobile number' })
|
|
||||||
otpRequestAdmin(@Body() dto: RequestOtpDto) {
|
otpRequestAdmin(@Body() dto: RequestOtpDto) {
|
||||||
return this.authService.requestOtp(dto, true);
|
return this.authService.requestOtp(dto, true);
|
||||||
}
|
}
|
||||||
@@ -51,8 +45,6 @@ export class AuthController {
|
|||||||
@Post('admin/auth/otp/verify')
|
@Post('admin/auth/otp/verify')
|
||||||
@ApiOperation({ summary: 'Verify OTP code' })
|
@ApiOperation({ summary: 'Verify OTP code' })
|
||||||
@ApiBody({ type: VerifyOtpDto, description: 'Mobile number and OTP code' })
|
@ApiBody({ type: VerifyOtpDto, description: 'Mobile number and OTP code' })
|
||||||
@ApiResponse({ status: 200, description: 'OTP verified successfully' })
|
|
||||||
@ApiResponse({ status: 400, description: 'Invalid OTP or expired' })
|
|
||||||
otpVerifyAdmin(@Body() dto: VerifyOtpDto) {
|
otpVerifyAdmin(@Body() dto: VerifyOtpDto) {
|
||||||
return this.authService.verifyOtpAdmin(dto.phone, dto.slug, dto.otp);
|
return this.authService.verifyOtpAdmin(dto.phone, dto.slug, dto.otp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { SetPaymentMethodDto } from '../dto/set-payment-method.dto';
|
|||||||
import { SetDeliveryMethodDto } from '../dto/set-delivery-method.dto';
|
import { SetDeliveryMethodDto } from '../dto/set-delivery-method.dto';
|
||||||
import { SetDescriptionDto } from '../dto/set-description.dto';
|
import { SetDescriptionDto } from '../dto/set-description.dto';
|
||||||
import { SetTableNumberDto } from '../dto/set-table-number.dto';
|
import { SetTableNumberDto } from '../dto/set-table-number.dto';
|
||||||
import { ApiTags, ApiOperation, ApiResponse, ApiBearerAuth, ApiBody, ApiParam } from '@nestjs/swagger';
|
import { ApiTags, ApiOperation, ApiBearerAuth, ApiBody, ApiParam } from '@nestjs/swagger';
|
||||||
import { AuthGuard } from '../../auth/guards/auth.guard';
|
import { AuthGuard } from '../../auth/guards/auth.guard';
|
||||||
import { UserId } from 'src/common/decorators/user-id.decorator';
|
import { UserId } from 'src/common/decorators/user-id.decorator';
|
||||||
import { RestId } from 'src/common/decorators/rest-id.decorator';
|
import { RestId } from 'src/common/decorators/rest-id.decorator';
|
||||||
@@ -67,15 +67,12 @@ export class CartController {
|
|||||||
@Delete('items/:foodId')
|
@Delete('items/:foodId')
|
||||||
@ApiOperation({ summary: 'Remove item from cart' })
|
@ApiOperation({ summary: 'Remove item from cart' })
|
||||||
@ApiParam({ name: 'foodId', description: 'Food ID in the cart' })
|
@ApiParam({ name: 'foodId', description: 'Food ID in the cart' })
|
||||||
@ApiResponse({ status: 200, description: 'Item removed from cart successfully' })
|
|
||||||
@ApiResponse({ status: 404, description: 'Item not found in cart' })
|
|
||||||
async removeItem(@UserId() userId: string, @RestId() restaurantId: string, @Param('foodId') foodId: string) {
|
async removeItem(@UserId() userId: string, @RestId() restaurantId: string, @Param('foodId') foodId: string) {
|
||||||
return this.cartService.removeItem(userId, restaurantId, foodId);
|
return this.cartService.removeItem(userId, restaurantId, foodId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete()
|
@Delete()
|
||||||
@ApiOperation({ summary: 'Clear entire cart' })
|
@ApiOperation({ summary: 'Clear entire cart' })
|
||||||
@ApiResponse({ status: 200, description: 'Cart cleared successfully' })
|
|
||||||
async clearCart(@UserId() userId: string, @RestId() restaurantId: string) {
|
async clearCart(@UserId() userId: string, @RestId() restaurantId: string) {
|
||||||
return this.cartService.clearCart(userId, restaurantId);
|
return this.cartService.clearCart(userId, restaurantId);
|
||||||
}
|
}
|
||||||
@@ -89,7 +86,6 @@ export class CartController {
|
|||||||
|
|
||||||
@Delete('coupon')
|
@Delete('coupon')
|
||||||
@ApiOperation({ summary: 'Remove coupon from cart' })
|
@ApiOperation({ summary: 'Remove coupon from cart' })
|
||||||
@ApiResponse({ status: 200, description: 'Coupon removed successfully' })
|
|
||||||
async removeCoupon(@UserId() userId: string, @RestId() restaurantId: string) {
|
async removeCoupon(@UserId() userId: string, @RestId() restaurantId: string) {
|
||||||
return this.cartService.removeCoupon(userId, restaurantId);
|
return this.cartService.removeCoupon(userId, restaurantId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { ContactService } from '../providers/contact.service';
|
|||||||
import { CreateContactDto } from '../dto/create-contact.dto';
|
import { CreateContactDto } from '../dto/create-contact.dto';
|
||||||
import { FindContactsDto } from '../dto/find-contacts.dto';
|
import { FindContactsDto } from '../dto/find-contacts.dto';
|
||||||
import { UpdateContactStatusDto } from '../dto/update-contact-status.dto';
|
import { UpdateContactStatusDto } from '../dto/update-contact-status.dto';
|
||||||
import { ApiTags, ApiOperation, ApiResponse, ApiBearerAuth, ApiParam, ApiQuery } from '@nestjs/swagger';
|
import { ApiTags, ApiOperation, ApiBearerAuth, ApiParam, ApiQuery } from '@nestjs/swagger';
|
||||||
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
|
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
|
||||||
|
|
||||||
@ApiTags('contact')
|
@ApiTags('contact')
|
||||||
@@ -25,7 +25,6 @@ export class ContactController {
|
|||||||
|
|
||||||
@Post('public/contact')
|
@Post('public/contact')
|
||||||
@ApiOperation({ summary: 'Create a new contact (public endpoint)' })
|
@ApiOperation({ summary: 'Create a new contact (public endpoint)' })
|
||||||
@ApiResponse({ status: 201, description: 'Contact created successfully' })
|
|
||||||
async create(@Body() createContactDto: CreateContactDto) {
|
async create(@Body() createContactDto: CreateContactDto) {
|
||||||
return this.contactService.create(createContactDto);
|
return this.contactService.create(createContactDto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { FindCouponsDto } from '../dto/find-coupons.dto';
|
|||||||
import {
|
import {
|
||||||
ApiTags,
|
ApiTags,
|
||||||
ApiOperation,
|
ApiOperation,
|
||||||
ApiResponse,
|
|
||||||
ApiCreatedResponse,
|
ApiCreatedResponse,
|
||||||
ApiOkResponse,
|
ApiOkResponse,
|
||||||
ApiNotFoundResponse,
|
ApiNotFoundResponse,
|
||||||
@@ -93,7 +92,6 @@ export class CouponController {
|
|||||||
@Delete('admin/coupons/:id')
|
@Delete('admin/coupons/:id')
|
||||||
@ApiOperation({ summary: 'Delete (soft) a coupon' })
|
@ApiOperation({ summary: 'Delete (soft) a coupon' })
|
||||||
@ApiParam({ name: 'id', required: true })
|
@ApiParam({ name: 'id', required: true })
|
||||||
@ApiResponse({ status: 200, description: 'Coupon deleted' })
|
|
||||||
remove(@Param('id') id: string) {
|
remove(@Param('id') id: string) {
|
||||||
return this.couponService.remove(id);
|
return this.couponService.remove(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { FindFoodsDto } from '../dto/find-foods.dto';
|
|||||||
import {
|
import {
|
||||||
ApiTags,
|
ApiTags,
|
||||||
ApiOperation,
|
ApiOperation,
|
||||||
ApiResponse,
|
|
||||||
ApiCreatedResponse,
|
ApiCreatedResponse,
|
||||||
ApiOkResponse,
|
ApiOkResponse,
|
||||||
ApiNotFoundResponse,
|
ApiNotFoundResponse,
|
||||||
@@ -83,7 +82,6 @@ export class FoodController {
|
|||||||
@Delete('admin/foods/:id')
|
@Delete('admin/foods/:id')
|
||||||
@ApiOperation({ summary: 'Delete (soft) a food' })
|
@ApiOperation({ summary: 'Delete (soft) a food' })
|
||||||
@ApiParam({ name: 'id', required: true })
|
@ApiParam({ name: 'id', required: true })
|
||||||
@ApiResponse({ status: 200, description: 'Food deleted' })
|
|
||||||
remove(@Param('id') id: string) {
|
remove(@Param('id') id: string) {
|
||||||
return this.foodsService.remove(id);
|
return this.foodsService.remove(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,7 @@ import { RestaurantsService } from '../providers/restaurants.service';
|
|||||||
import { CreateRestaurantDto } from '../dto/create-restaurant.dto';
|
import { CreateRestaurantDto } from '../dto/create-restaurant.dto';
|
||||||
import { UpdateRestaurantDto } from '../dto/update-restaurant.dto';
|
import { UpdateRestaurantDto } from '../dto/update-restaurant.dto';
|
||||||
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
|
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
|
||||||
import {
|
import { ApiBearerAuth, ApiBody, ApiNotFoundResponse, ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger';
|
||||||
ApiBearerAuth,
|
|
||||||
ApiBody,
|
|
||||||
ApiNotFoundResponse,
|
|
||||||
ApiOperation,
|
|
||||||
ApiParam,
|
|
||||||
ApiResponse,
|
|
||||||
ApiTags,
|
|
||||||
} from '@nestjs/swagger';
|
|
||||||
import { RestId } from 'src/common/decorators';
|
import { RestId } from 'src/common/decorators';
|
||||||
|
|
||||||
@ApiTags('restaurants')
|
@ApiTags('restaurants')
|
||||||
@@ -32,7 +24,6 @@ export class RestaurantsController {
|
|||||||
@Post('admin/restaurants')
|
@Post('admin/restaurants')
|
||||||
@ApiOperation({ summary: 'Create a new restaurant' })
|
@ApiOperation({ summary: 'Create a new restaurant' })
|
||||||
@ApiBody({ type: CreateRestaurantDto })
|
@ApiBody({ type: CreateRestaurantDto })
|
||||||
@ApiResponse({ status: 201, description: 'Restaurant created' })
|
|
||||||
create(@Body() createRestaurantDto: CreateRestaurantDto) {
|
create(@Body() createRestaurantDto: CreateRestaurantDto) {
|
||||||
return this.restaurantsService.create(createRestaurantDto);
|
return this.restaurantsService.create(createRestaurantDto);
|
||||||
}
|
}
|
||||||
@@ -41,7 +32,6 @@ export class RestaurantsController {
|
|||||||
// @UseGuards(AdminAuthGuard)
|
// @UseGuards(AdminAuthGuard)
|
||||||
// @ApiBearerAuth()
|
// @ApiBearerAuth()
|
||||||
// @ApiOperation({ summary: 'Get all restaurants' })
|
// @ApiOperation({ summary: 'Get all restaurants' })
|
||||||
// @ApiResponse({ status: 200, description: 'Restaurants found' })
|
|
||||||
// findAll() {
|
// findAll() {
|
||||||
// return this.restaurantsService.findAll();
|
// return this.restaurantsService.findAll();
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import { ChangeStatusDto } from '../dto/change-status.dto';
|
|||||||
import {
|
import {
|
||||||
ApiTags,
|
ApiTags,
|
||||||
ApiOperation,
|
ApiOperation,
|
||||||
ApiResponse,
|
|
||||||
ApiCreatedResponse,
|
ApiCreatedResponse,
|
||||||
ApiOkResponse,
|
ApiOkResponse,
|
||||||
ApiQuery,
|
ApiQuery,
|
||||||
@@ -87,7 +86,6 @@ export class ReviewController {
|
|||||||
@Delete('public/reviews/:id')
|
@Delete('public/reviews/:id')
|
||||||
@ApiOperation({ summary: 'Delete a review (own reviews only)' })
|
@ApiOperation({ summary: 'Delete a review (own reviews only)' })
|
||||||
@ApiParam({ name: 'id', required: true })
|
@ApiParam({ name: 'id', required: true })
|
||||||
@ApiResponse({ status: 200, description: 'Review deleted' })
|
|
||||||
remove(@Param('id') id: string, @UserId() userId: string) {
|
remove(@Param('id') id: string, @UserId() userId: string) {
|
||||||
return this.reviewService.remove(id, userId, false);
|
return this.reviewService.remove(id, userId, false);
|
||||||
}
|
}
|
||||||
@@ -146,7 +144,6 @@ export class ReviewController {
|
|||||||
@Delete('admin/reviews/:id')
|
@Delete('admin/reviews/:id')
|
||||||
@ApiOperation({ summary: 'Delete a review (admin)' })
|
@ApiOperation({ summary: 'Delete a review (admin)' })
|
||||||
@ApiParam({ name: 'id', required: true })
|
@ApiParam({ name: 'id', required: true })
|
||||||
@ApiResponse({ status: 200, description: 'Review deleted' })
|
|
||||||
removeAdmin(@Param('id') id: string, @UserId() userId: string) {
|
removeAdmin(@Param('id') id: string, @UserId() userId: string) {
|
||||||
return this.reviewService.remove(id, userId, true);
|
return this.reviewService.remove(id, userId, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Controller, Get, Post, Body, Param, Patch, Delete, UseGuards } from '@nestjs/common';
|
import { Controller, Get, Post, Body, Param, Patch, Delete, UseGuards } from '@nestjs/common';
|
||||||
import { ApiTags, ApiOperation, ApiBody, ApiResponse, ApiBearerAuth } from '@nestjs/swagger';
|
import { ApiTags, ApiOperation, ApiBody, ApiBearerAuth } from '@nestjs/swagger';
|
||||||
import { RolesService } from '../providers/roles.service';
|
import { RolesService } from '../providers/roles.service';
|
||||||
import { PermissionsService } from '../providers/permissions.service';
|
import { PermissionsService } from '../providers/permissions.service';
|
||||||
import { CreateRoleDto } from '../dto/create-role.dto';
|
import { CreateRoleDto } from '../dto/create-role.dto';
|
||||||
@@ -21,14 +21,12 @@ export class RolesController {
|
|||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@ApiOperation({ summary: 'Get all through restaurant roles with pagination and filters' })
|
@ApiOperation({ summary: 'Get all through restaurant roles with pagination and filters' })
|
||||||
@ApiResponse({ status: 200, description: 'Restaurant roles retrieved successfully' })
|
|
||||||
findAll(@RestId() restId: string) {
|
findAll(@RestId() restId: string) {
|
||||||
return this.roleService.findAllGeneralAndRestaurantRoles(restId);
|
return this.roleService.findAllGeneralAndRestaurantRoles(restId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('permissions')
|
@Get('permissions')
|
||||||
@ApiOperation({ summary: 'Get all permissions that the admin has' })
|
@ApiOperation({ summary: 'Get all permissions that the admin has' })
|
||||||
@ApiResponse({ status: 200, description: 'Permissions retrieved successfully' })
|
|
||||||
async findAllPermissions(@AdminId() adminId: string, @RestId() restId: string) {
|
async findAllPermissions(@AdminId() adminId: string, @RestId() restId: string) {
|
||||||
const adminPermissionNames = await this.permissionService.getAdminFullPermissions(adminId, restId);
|
const adminPermissionNames = await this.permissionService.getAdminFullPermissions(adminId, restId);
|
||||||
|
|
||||||
@@ -39,15 +37,12 @@ export class RolesController {
|
|||||||
@Post()
|
@Post()
|
||||||
@ApiOperation({ summary: 'Create a new role' })
|
@ApiOperation({ summary: 'Create a new role' })
|
||||||
@ApiBody({ type: CreateRoleDto })
|
@ApiBody({ type: CreateRoleDto })
|
||||||
@ApiResponse({ status: 201, description: 'Role created successfully' })
|
|
||||||
create(@Body() dto: CreateRoleDto, @RestId() restId: string) {
|
create(@Body() dto: CreateRoleDto, @RestId() restId: string) {
|
||||||
return this.roleService.createRestaurantRole(dto, restId);
|
return this.roleService.createRestaurantRole(dto, restId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
@ApiOperation({ summary: 'Get a specific role by ID' })
|
@ApiOperation({ summary: 'Get a specific role by ID' })
|
||||||
@ApiResponse({ status: 200, description: 'Role retrieved successfully' })
|
|
||||||
@ApiResponse({ status: 404, description: 'Role not found' })
|
|
||||||
findOne(@Param('id') id: string, @RestId() restId: string) {
|
findOne(@Param('id') id: string, @RestId() restId: string) {
|
||||||
return this.roleService.findOne(restId, id);
|
return this.roleService.findOne(restId, id);
|
||||||
}
|
}
|
||||||
@@ -55,16 +50,12 @@ export class RolesController {
|
|||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
@ApiOperation({ summary: 'Update a role' })
|
@ApiOperation({ summary: 'Update a role' })
|
||||||
@ApiBody({ type: UpdateRoleDto })
|
@ApiBody({ type: UpdateRoleDto })
|
||||||
@ApiResponse({ status: 200, description: 'Role updated successfully' })
|
|
||||||
@ApiResponse({ status: 404, description: 'Role not found' })
|
|
||||||
update(@Param('id') id: string, @Body() dto: UpdateRoleDto, @RestId() restId: string) {
|
update(@Param('id') id: string, @Body() dto: UpdateRoleDto, @RestId() restId: string) {
|
||||||
return this.roleService.update(restId, id, dto);
|
return this.roleService.update(restId, id, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
@ApiOperation({ summary: 'Delete a role' })
|
@ApiOperation({ summary: 'Delete a role' })
|
||||||
@ApiResponse({ status: 200, description: 'Role deleted successfully' })
|
|
||||||
@ApiResponse({ status: 404, description: 'Role not found' })
|
|
||||||
remove(@Param('id') id: string, @RestId() restId: string) {
|
remove(@Param('id') id: string, @RestId() restId: string) {
|
||||||
return this.roleService.remove(restId, id);
|
return this.roleService.remove(restId, id);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": true,
|
||||||
"strictBindCallApply": false,
|
"strictBindCallApply": false,
|
||||||
"noFallthroughCasesInSwitch": false,
|
"noFallthroughCasesInSwitch": false,
|
||||||
"baseUrl": "./",
|
"baseUrl": "./",
|
||||||
|
|||||||
Reference in New Issue
Block a user