/*
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import {
Body,
Controller,
Delete,
Get,
InternalServerErrorException,
NotFoundException,
Param,
Patch,
Post,
Query,
UseInterceptors,
} from '@nestjs/common';
import { CsrfCheck } from '@tekuconcept/nestjs-csrf';
import { CsrfInterceptor } from '@/interceptors/csrf.interceptor';
import { BaseController } from '@/utils/generics/base-controller';
import { PageQueryDto } from '@/utils/pagination/pagination-query.dto';
import { PageQueryPipe } from '@/utils/pagination/pagination-query.pipe';
import { SearchFilterPipe } from '@/utils/pipes/search-filter.pipe';
import { TFilterQuery } from '@/utils/types/filter.types';
import { MenuCreateDto, MenuQueryDto } from '../dto/menu.dto';
import { Menu, MenuFull, MenuPopulate, MenuStub } from '../schemas/menu.schema';
import { MenuService } from '../services/menu.service';
@UseInterceptors(CsrfInterceptor)
@Controller('menu')
export class MenuController extends BaseController<
Menu,
MenuStub,
MenuPopulate,
MenuFull
> {
constructor(private readonly menuService: MenuService) {
super(menuService);
}
/**
* Counts the filtered number of menu items.
*
* Applies filtering based on the allowed fields and returns the number of matching menus.
*
* @returns A promise that resolves to the count of filtered menu items.
*/
@Get('count')
async filterCount(
@Query(new SearchFilterPipe