Skip to content

Commit fbb1812

Browse files
committed
feat: change search endpoint to use GET method with query parameters
1 parent 20b92ee commit fbb1812

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

api/src/search/controller.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Controller, Post, Body, ContentType } from "routing-controllers";
1+
import { Controller, Get, QueryParams } from "routing-controllers";
22

3-
import { SearchRequest, SearchResponse } from "./types";
3+
import { SearchQuery, SearchResponse } from "./types";
44
import { SearchService } from "./service";
55
import { Service } from "typedi";
66

@@ -9,9 +9,8 @@ import { Service } from "typedi";
99
export class SearchController {
1010
constructor(private readonly searchService: SearchService) {}
1111

12-
@Post("/")
13-
@ContentType("application/json")
14-
public async search(@Body({ required: true }) req: SearchRequest): Promise<SearchResponse> {
12+
@Get("/")
13+
public async search(@QueryParams({ required: true }) req: SearchQuery): Promise<SearchResponse> {
1514
const searchResults = await this.searchService.search(req.query, req.limit);
1615
return {
1716
searchResults,

api/src/search/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { MultiSearchResponse } from "meilisearch";
55
import { ProjectEntity } from "@dzcode.io/models/dist/project";
66
import { IsNotEmpty, IsPositive, IsString } from "class-validator";
77

8-
export class SearchRequest {
8+
export class SearchQuery {
99
@IsString()
1010
@IsNotEmpty()
1111
query!: string;

0 commit comments

Comments
 (0)