Skip to content

Commit bd648c5

Browse files
committed
sorting fix
1 parent 64c1c16 commit bd648c5

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

source/api/v1/api/handlers/notes/NotesHandlers.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FastifyInstance } from "fastify";
2-
import { INotesService } from "../../../services/notes/NotesServiceInterface";
2+
import { INotesService, NotesSearchOptions } from "../../../services/notes/NotesServiceInterface";
33
import { NoteUpdate, NoteWithoutMetadata } from "../../../shared/dto/NoteDto";
44
import { extractJwtPayload } from "../../../shared/utils/jwt/PayloadExtractor";
55
import { extractToken } from "../../../shared/utils/common/TokenExtractor";
@@ -41,12 +41,7 @@ export class NotesHandler implements Handler {
4141
})
4242

4343
this.server.get<{
44-
Querystring: {
45-
limit: number,
46-
offset: number,
47-
date_sort: "ASC" | "DESC",
48-
tags: string[]
49-
},
44+
Querystring: NotesSearchOptions,
5045
}>("/notes/my",
5146
{
5247
schema: GetNotesSchema,
@@ -70,12 +65,7 @@ export class NotesHandler implements Handler {
7065
})
7166

7267
this.server.get<{
73-
Querystring: {
74-
limit: number,
75-
offset: number,
76-
sort: "ASC" | "DESC",
77-
tags: string[]
78-
},
68+
Querystring: NotesSearchOptions,
7969
}>("/notes/collaborated", {
8070
schema: GetNotesSchema,
8171
preHandler: this.authorizationPreHandler
@@ -84,12 +74,9 @@ export class NotesHandler implements Handler {
8474
extractToken(request)
8575
)
8676

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
9178

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})
9380
if (isException(notes)) {
9481
reply.code(notes.statusCode).send(notes)
9582
return

0 commit comments

Comments
 (0)