-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Manuel Ruck <[email protected]>
- Loading branch information
Manuel Ruck
committed
Sep 23, 2024
1 parent
9cf873d
commit 29defaa
Showing
13 changed files
with
207 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
vars { | ||
url: http://localhost:3000 | ||
url: http://localhost:3006 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createParamDecorator, ExecutionContext } from '@nestjs/common'; | ||
|
||
export const Pagination = createParamDecorator( | ||
(data: unknown, ctx: ExecutionContext) => { | ||
const request = ctx.switchToHttp().getRequest(); | ||
const { page = 1, limit = 10 } = request.query; | ||
|
||
// Ensure valid pagination values | ||
const validPage = Math.max(1, parseInt(page)); | ||
const validLimit = Math.min(Math.max(1, parseInt(limit)), 100); // Max limit of 100 | ||
|
||
return { page: validPage, limit: validLimit }; | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 18 additions & 6 deletions
24
services/procedures/src/procedures/procedures.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,33 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
import { ProceduresService } from './procedures.service'; | ||
import { Pagination } from '../decorators/pagination'; | ||
|
||
@Controller('procedures') | ||
export class ProceduresController { | ||
constructor(private readonly proceduresService: ProceduresService) {} | ||
@Get() | ||
findAll() { | ||
return this.proceduresService.findAll(); | ||
findAll(@Pagination() pagination: { page: number; limit: number }) { | ||
return this.proceduresService.findAll({ | ||
page: pagination.page, | ||
limit: pagination.limit, | ||
}); | ||
} | ||
|
||
@Get('list/upcoming') | ||
upcomingProcedures() { | ||
return this.proceduresService.fetchUpcomingProcedures(); | ||
upcomingProcedures( | ||
@Pagination() pagination: { page: number; limit: number }, | ||
) { | ||
return this.proceduresService.fetchUpcomingProcedures({ | ||
page: pagination.page, | ||
limit: pagination.limit, | ||
}); | ||
} | ||
|
||
@Get('list/past') | ||
pastProcedures() { | ||
return this.proceduresService.fetchPastProcedures(); | ||
pastProcedures(@Pagination() pagination: { page: number; limit: number }) { | ||
return this.proceduresService.fetchPastProcedures({ | ||
page: pagination.page, | ||
limit: pagination.limit, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.