-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add controller for retrieving workspace members
- Loading branch information
Showing
2 changed files
with
45 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,40 @@ | ||
import { Controller } from "@nestjs/common"; | ||
import { Controller, DefaultValuePipe, Get, Param, ParseIntPipe, Query, Req } from "@nestjs/common"; | ||
import { ApiBearerAuth, ApiFoundResponse, ApiOperation, ApiQuery, ApiTags } from "@nestjs/swagger"; | ||
import { FindWorkspaceUsersResponse } from "./types/find-workspace-users-response.type"; | ||
import { AuthroizedRequest } from "src/utils/types/req.type"; | ||
import { WorkspaceUsersService } from "./workspace-users.service"; | ||
|
||
@Controller("workspace-users") | ||
export class WorkspaceUsersController {} | ||
@ApiTags("Workspace.Users") | ||
@ApiBearerAuth() | ||
@Controller("workspaces/:workspace_id/users") | ||
export class WorkspaceUsersController { | ||
constructor(private workspaceUsersService: WorkspaceUsersService) {} | ||
|
||
@Get("") | ||
@ApiOperation({ | ||
summary: "Retrieve the Users in Workspace", | ||
description: "Return the users in the workspace. This API supports KeySet pagination.", | ||
}) | ||
@ApiFoundResponse({ type: FindWorkspaceUsersResponse }) | ||
@ApiQuery({ | ||
name: "page_size", | ||
type: Number, | ||
description: "Page size to fetch (Default to 10)", | ||
required: false, | ||
}) | ||
@ApiQuery({ | ||
name: "cursor", | ||
type: String, | ||
description: | ||
"API returns a limited set of results after a given cursor. If no value is provided, it returns the first page.", | ||
required: false, | ||
}) | ||
async findMany( | ||
@Req() req: AuthroizedRequest, | ||
@Param("workspace_id") workspaceId: string, | ||
@Query("page_size", new DefaultValuePipe(10), ParseIntPipe) pageSize: number, | ||
@Query("cursor", new DefaultValuePipe(undefined)) cursor?: string | ||
): Promise<FindWorkspaceUsersResponse> { | ||
return this.workspaceUsersService.findMany(req.user.id, workspaceId, pageSize, cursor); | ||
} | ||
} |
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