add recent searches module

This commit is contained in:
Jurgis Sakalauskas
2022-12-09 18:09:04 +02:00
parent 7e5fa1fb2a
commit cd4ba620de
9 changed files with 94 additions and 11 deletions
+11 -1
View File
@@ -2,10 +2,14 @@ import { Controller, Get, Param, Query, Req } from '@nestjs/common';
import { Request } from 'express';
import { LrtService } from './lrt.service';
import ApiResponse from '../Dto/api-response.dto';
import { RecentSearchesService } from '../RecentSearches/recent-searches.service';
@Controller('api/lrt')
export class LrtController {
constructor(private readonly lrtService: LrtService) {}
constructor(
private readonly lrtService: LrtService,
private readonly recentSearchesService: RecentSearchesService,
) {}
@Get()
getLrtMenu(): ApiResponse {
@@ -14,9 +18,15 @@ export class LrtController {
@Get('search')
getSearch(@Query('search') search: string): Promise<ApiResponse> {
this.recentSearchesService.addRecentSearch('lrt', search).then();
return this.lrtService.searchCategories(search);
}
@Get('recent')
getRecent(): Promise<ApiResponse> {
return this.lrtService.getRecentSearches();
}
@Get('cat/:id')
async getCategory(@Param('id') id: string): Promise<ApiResponse> {
return this.lrtService.getCategory(id);