1
1
import { FastifyInstance } from "fastify" ;
2
- import { INotesService } from "../../../services/notes/NotesServiceInterface" ;
2
+ import { INotesService , NotesSearchOptions } from "../../../services/notes/NotesServiceInterface" ;
3
3
import { NoteUpdate , NoteWithoutMetadata } from "../../../shared/dto/NoteDto" ;
4
4
import { extractJwtPayload } from "../../../shared/utils/jwt/PayloadExtractor" ;
5
5
import { extractToken } from "../../../shared/utils/common/TokenExtractor" ;
@@ -41,12 +41,7 @@ export class NotesHandler implements Handler {
41
41
} )
42
42
43
43
this . server . get < {
44
- Querystring : {
45
- limit : number ,
46
- offset : number ,
47
- date_sort : "ASC" | "DESC" ,
48
- tags : string [ ]
49
- } ,
44
+ Querystring : NotesSearchOptions ,
50
45
} > ( "/notes/my" ,
51
46
{
52
47
schema : GetNotesSchema ,
@@ -70,12 +65,7 @@ export class NotesHandler implements Handler {
70
65
} )
71
66
72
67
this . server . get < {
73
- Querystring : {
74
- limit : number ,
75
- offset : number ,
76
- sort : "ASC" | "DESC" ,
77
- tags : string [ ]
78
- } ,
68
+ Querystring : NotesSearchOptions ,
79
69
} > ( "/notes/collaborated" , {
80
70
schema : GetNotesSchema ,
81
71
preHandler : this . authorizationPreHandler
@@ -84,12 +74,9 @@ export class NotesHandler implements Handler {
84
74
extractToken ( request )
85
75
)
86
76
87
- const limit = request . query . limit
88
- const skip = request . query . offset
89
- const sort = request . query . sort
90
- const tags = request . query . tags
77
+ const { limit, offset, date_sort, tags} = request . query
91
78
92
- const notes = await this . notesService . getCollaboratedNotes ( login , { tags, limit, offset : skip , date_sort : sort } )
79
+ const notes = await this . notesService . getCollaboratedNotes ( login , { tags, limit, offset, date_sort} )
93
80
if ( isException ( notes ) ) {
94
81
reply . code ( notes . statusCode ) . send ( notes )
95
82
return
0 commit comments