Add CRUD endpoints for GroupsController

Implemented GET, POST, and DELETE endpoints in GroupsController to manage groups and associated files with pagination and optional search functionality. Created an ISearchQuery interface to standardize query parameters across methods.
This commit is contained in:
Mathis H (Avnyr) 2024-09-23 12:08:21 +02:00
parent 6a759bd693
commit 1881a7e6c4
Signed by: Mathis
GPG Key ID: DD9E0666A747D126
3 changed files with 42 additions and 1 deletions

View File

@ -1,7 +1,43 @@
import { Controller } from '@nestjs/common';
import { Controller, DefaultValuePipe, Delete, Get, Param, ParseIntPipe, Post, Query } from '@nestjs/common';
import { GroupsService } from './groups.service';
import { ISearchQuery } from 'apps/backend/src/app/groups/groups.types';
@Controller('groups')
export class GroupsController {
constructor(private readonly groupsService: GroupsService) {}
//GET all groups with limit and offset + optional search
@Get()
async findMany(
@Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number,
@Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number,
@Query("search", new DefaultValuePipe("")) search: string
) {
const query = {limit, offset, search}
}
//POST a new group
@Post("new")
async newGroup() {
}
//DELETE a group
@Delete(":groupId")
async deleteGroup(@Param('groupId') groupId: string) {
}
//GET files associated to group with limit and offset
@Get(":groupId")
async getForGroup(
@Query("limit", new DefaultValuePipe(20), ParseIntPipe) limit: number,
@Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number,
@Query("search", new DefaultValuePipe("")) search: string,
@Param('groupId') groupId: string
) {
const query = {limit, offset, search}
}
}

View File

@ -0,0 +1,5 @@
export interface ISearchQuery {
limit: number;
offset: number;
search?: string;
}