fix: address code review feedback
- Add explicit return types to all SearchController methods - Import necessary types (PaginatedSearchResults, PaginatedEntries) - Define RecentEntriesResponse interface for type safety - Ensures compliance with TypeScript strict typing standards
This commit is contained in:
@@ -1,9 +1,21 @@
|
||||
import { Controller, Get, Query, UseGuards } from "@nestjs/common";
|
||||
import { SearchService } from "./services/search.service";
|
||||
import { SearchService, PaginatedSearchResults } from "./services/search.service";
|
||||
import { SearchQueryDto, TagSearchDto, RecentEntriesDto } from "./dto";
|
||||
import { AuthGuard } from "../auth/guards/auth.guard";
|
||||
import { WorkspaceGuard, PermissionGuard } from "../common/guards";
|
||||
import { Workspace, Permission, RequirePermission } from "../common/decorators";
|
||||
import type {
|
||||
PaginatedEntries,
|
||||
KnowledgeEntryWithTags,
|
||||
} from "./entities/knowledge-entry.entity";
|
||||
|
||||
/**
|
||||
* Response for recent entries endpoint
|
||||
*/
|
||||
interface RecentEntriesResponse {
|
||||
data: KnowledgeEntryWithTags[];
|
||||
count: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller for knowledge search endpoints
|
||||
@@ -30,7 +42,7 @@ export class SearchController {
|
||||
async search(
|
||||
@Workspace() workspaceId: string,
|
||||
@Query() query: SearchQueryDto
|
||||
) {
|
||||
): Promise<PaginatedSearchResults> {
|
||||
return this.searchService.search(query.q, workspaceId, {
|
||||
status: query.status,
|
||||
page: query.page,
|
||||
@@ -53,7 +65,7 @@ export class SearchController {
|
||||
async searchByTags(
|
||||
@Workspace() workspaceId: string,
|
||||
@Query() query: TagSearchDto
|
||||
) {
|
||||
): Promise<PaginatedEntries> {
|
||||
return this.searchService.searchByTags(query.tags, workspaceId, {
|
||||
status: query.status,
|
||||
page: query.page,
|
||||
@@ -74,7 +86,7 @@ export class SearchController {
|
||||
async recentEntries(
|
||||
@Workspace() workspaceId: string,
|
||||
@Query() query: RecentEntriesDto
|
||||
) {
|
||||
): Promise<RecentEntriesResponse> {
|
||||
const entries = await this.searchService.recentEntries(
|
||||
workspaceId,
|
||||
query.limit || 10,
|
||||
|
||||
Reference in New Issue
Block a user