forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.controller.ts
More file actions
70 lines (65 loc) · 1.86 KB
/
Copy pathsearch.controller.ts
File metadata and controls
70 lines (65 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import {
Controller,
Post,
Body,
HttpCode,
HttpStatus,
ValidationPipe,
} from '@nestjs/common';
import {
ApiTags,
ApiOperation,
ApiResponse,
ApiBody,
} from '@nestjs/swagger';
import { SearchService } from './search.service';
import { SearchSplitsDto } from './dto/search-splits.dto';
import { SearchResultDto } from './dto/search-result.dto';
/**
* Controller for search endpoints
* I'm keeping this focused on splits for now, but the structure
* allows easy extension to search participants/transactions separately
*/
@ApiTags('Search')
@Controller('search')
export class SearchController {
constructor(private readonly searchService: SearchService) {}
@Post('splits')
@HttpCode(HttpStatus.OK)
@ApiOperation({
summary: 'Search splits with full-text search and filters',
description: `
Performs full-text search across split descriptions and item names.
Supports fuzzy matching for typo tolerance.
**Filters:**
- Date range (dateFrom, dateTo)
- Amount range (minAmount, maxAmount)
- Status (active, completed, partial)
- Participants (user IDs)
**Sorting:**
- createdAt_desc (default)
- createdAt_asc
- amount_desc
- amount_asc
**Pagination:**
Uses cursor-based pagination for stable results.
Pass the cursor from the previous response to get the next page.
`
})
@ApiBody({ type: SearchSplitsDto })
@ApiResponse({
status: 200,
description: 'Search results with highlighted matches',
type: SearchResultDto,
})
@ApiResponse({
status: 400,
description: 'Invalid search parameters',
})
async searchSplits(
@Body(new ValidationPipe({ transform: true, whitelist: true }))
searchDto: SearchSplitsDto,
): Promise<SearchResultDto> {
return this.searchService.searchSplits(searchDto);
}
}