-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
75 additions
and
8 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
33 changes: 33 additions & 0 deletions
33
src/activities/activities-repository/activities-repository.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { | ||
Controller, | ||
Get, | ||
Query, | ||
UseGuards, | ||
UseInterceptors, | ||
} from "@nestjs/common"; | ||
import { ApiOkResponse, ApiTags } from "@nestjs/swagger"; | ||
import { FindLatestActivitiesDto } from "./dto/find-latest-activities.dto"; | ||
import { ActivitiesRepositoryService } from "./activities-repository.service"; | ||
import { ActivitiesPaginatedResponseDto } from "./dto/activities-paginated-response.dto"; | ||
import { PaginationInterceptor } from "../../interceptor/pagination.interceptor"; | ||
import { AuthGuard } from "../../auth/auth.guard"; | ||
import { Public } from "../../auth/public.decorator"; | ||
|
||
@Controller("activities") | ||
@ApiTags("activities") | ||
@UseGuards(AuthGuard) | ||
export class ActivitiesRepositoryController { | ||
constructor( | ||
private readonly activitiesRepositoryService: ActivitiesRepositoryService, | ||
) {} | ||
|
||
@Get() | ||
@ApiOkResponse({ | ||
type: ActivitiesPaginatedResponseDto, | ||
}) | ||
@UseInterceptors(PaginationInterceptor) | ||
@Public() | ||
async findLatest(@Query() dto: FindLatestActivitiesDto) { | ||
return this.activitiesRepositoryService.findLatest(dto); | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
src/activities/activities-repository/dto/activities-paginated-response.dto.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Activity } from "../entities/activity.entity"; | ||
import { PaginationInfo } from "../../../utils/pagination/pagination-response.dto"; | ||
|
||
export class ActivitiesPaginatedResponseDto { | ||
data: Activity[]; | ||
pagination: PaginationInfo; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/activities/activities-repository/dto/find-latest-activities.dto.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { IsOptional, IsString, Length } from "class-validator"; | ||
import { OmitType } from "@nestjs/swagger"; | ||
import { BaseFindDto } from "../../../utils/base-find.dto"; | ||
import { Activity } from "../entities/activity.entity"; | ||
|
||
export class FindLatestActivitiesDto extends OmitType(BaseFindDto<Activity>, [ | ||
"orderBy", | ||
"search", | ||
]) { | ||
@IsOptional() | ||
@IsString() | ||
@Length(36) | ||
userId?: string; | ||
} |
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