import { Controller, Get, Post, Delete, Body, Param, Query, BadRequestException } from '@nestjs/common'; import { FFBProduction } from './ffb-production.schema'; import { FFBProductionService } from './services/ffb-production.service'; import { FFBLangChainService } from './services/ffb-langchain.service'; @Controller('ffb-production') export class FFBProductionController { constructor( private readonly ffbService: FFBProductionService, private readonly ffbLangChainService: FFBLangChainService, ) { } @Post('chat') async query(@Body('message') message: string, @Body('sessionId') sessionId?: string) { throw new BadRequestException('HTTP Chat endpoint is deprecated. Please use WebSocket connection on namespace /ffb with event "chat".'); } /** Vector search endpoint */ @Get('search') async search(@Query('q') q: string, @Query('k') k?: string) { console.log(`GET /ffb-production/search?q=${q}&k=${k}`); const topK = k ? parseInt(k, 10) : 5; return this.ffbService.search(q, topK); } /** Create a new FFB production record (with embedding) */ @Post() async create(@Body() body: FFBProduction) { console.log('POST /ffb-production'); return this.ffbService.create(body); } /** Find all records */ @Get() async findAll(@Query() query: any) { console.log('GET /ffb-production', query); return this.ffbService.findAll(query); } /** Find a record by ID */ @Get(':id') async findById(@Param('id') id: string) { console.log(`GET /ffb-production/${id}`); return this.ffbService.findById(id); } /** Delete a record by ID */ @Delete(':id') async delete(@Param('id') id: string) { console.log(`DELETE /ffb-production/${id}`); return this.ffbService.delete(id); } }