mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-19 10:01:23 +02:00
23 lines
795 B
TypeScript
23 lines
795 B
TypeScript
import { Controller, Get, Query, UseGuards } from '@nestjs/common';
|
|
import { JwtAuthGuard, CurrentUser } from '@manacore/shared-nestjs-auth';
|
|
import type { CurrentUserData } from '@manacore/shared-nestjs-auth';
|
|
import { SearchService } from './search.service';
|
|
|
|
@Controller('api/v1')
|
|
@UseGuards(JwtAuthGuard)
|
|
export class SearchController {
|
|
constructor(private readonly searchService: SearchService) {}
|
|
|
|
@Get('search')
|
|
async search(@CurrentUser() user: CurrentUserData, @Query('q') query: string) {
|
|
if (!query || query.trim().length === 0) {
|
|
return { files: [], folders: [] };
|
|
}
|
|
return this.searchService.search(user.userId, query.trim());
|
|
}
|
|
|
|
@Get('favorites')
|
|
async getFavorites(@CurrentUser() user: CurrentUserData) {
|
|
return this.searchService.getFavorites(user.userId);
|
|
}
|
|
}
|