Refactor GroupsController with route updates and guards
Renamed route for fetching groups and added an admin guard to the delete endpoint. Also updated the endpoint for getting files associated with a group and removed unnecessary method bodies and comments.
This commit is contained in:
parent
d3feeb6d6a
commit
e931822010
@ -7,42 +7,38 @@ import {
|
|||||||
Param,
|
Param,
|
||||||
ParseIntPipe,
|
ParseIntPipe,
|
||||||
Post,
|
Post,
|
||||||
Query,
|
Query, UseGuards
|
||||||
} from "@nestjs/common";
|
} from '@nestjs/common';
|
||||||
import { CreateGroupDto } from "apps/backend/src/app/groups/groups.dto";
|
import { CreateGroupDto } from "apps/backend/src/app/groups/groups.dto";
|
||||||
import { ISearchQuery } from "apps/backend/src/app/groups/groups.types";
|
import { ISearchQuery } from "apps/backend/src/app/groups/groups.types";
|
||||||
import { GroupsService } from "./groups.service";
|
import { GroupsService } from "./groups.service";
|
||||||
|
import { AdminGuard } from 'apps/backend/src/app/auth/auth.guard';
|
||||||
|
|
||||||
@Controller("groups")
|
@Controller("groups")
|
||||||
export class GroupsController {
|
export class GroupsController {
|
||||||
constructor(private readonly groupsService: GroupsService) {}
|
constructor(private readonly groupsService: GroupsService) {}
|
||||||
|
|
||||||
//GET all groups with limit and offset + optional search
|
@Get("find")
|
||||||
@Get()
|
|
||||||
async findMany(
|
async findMany(
|
||||||
@Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number,
|
@Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number,
|
||||||
@Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number,
|
@Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number,
|
||||||
@Query("search", new DefaultValuePipe("")) search: string,
|
@Query("search", new DefaultValuePipe("")) search: string,
|
||||||
) {
|
) {}
|
||||||
//TODO add service method
|
|
||||||
}
|
|
||||||
|
|
||||||
//POST a new group
|
|
||||||
@Post("new")
|
@Post("new")
|
||||||
async newGroup(@Body() dto: CreateGroupDto) {}
|
async newGroup() {}
|
||||||
|
|
||||||
//DELETE a group
|
@UseGuards(AdminGuard)
|
||||||
@Delete(":groupId")
|
@Delete(":groupId")
|
||||||
async deleteGroup(@Param("groupId") groupId: string) {}
|
async deleteGroup(@Param("groupId") groupId: string) {}
|
||||||
|
|
||||||
//GET files associated to group with limit and offset
|
//TODO Patch
|
||||||
@Get(":groupId")
|
|
||||||
async getForGroup(
|
@Get(":groupId/files")
|
||||||
|
async getFilesForGroup(
|
||||||
@Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number,
|
@Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number,
|
||||||
@Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number,
|
@Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number,
|
||||||
@Query("search", new DefaultValuePipe("")) search: string,
|
@Query("search", new DefaultValuePipe("")) search: string,
|
||||||
@Param("groupId") groupId: string,
|
@Param("groupId") groupId: string,
|
||||||
) {
|
) {}
|
||||||
const query = { limit, offset, search };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user