Add missing semicolons and format code for consistency

Updated the controllers and services by adding missing semicolons to ensure code consistency and prevent potential runtime errors. Reformatted the import statements to enhance readability and maintain a uniform style across the codebase.
This commit is contained in:
Mathis H (Avnyr) 2024-10-14 15:16:13 +02:00
parent 04cc2daf43
commit 1c78912f99
Signed by: Mathis
GPG Key ID: DD9E0666A747D126
2 changed files with 35 additions and 22 deletions

View File

@ -25,18 +25,18 @@ export class GroupsController {
@Query("offset", new DefaultValuePipe(0), ParseIntPipe) offset: number,
@Query("search", new DefaultValuePipe("")) search: string,
) {
return await this.groupsService.getGroupsByName(limit, offset, search)
return await this.groupsService.getGroupsByName(limit, offset, search);
}
@Post("new")
async newGroup(@Body() body: CreateGroupDto) {
return await this.groupsService.newGroup(body.groupName)
return await this.groupsService.newGroup(body.groupName);
}
@UseGuards(AdminGuard)
@Delete(":groupId")
async deleteGroup(@Param("groupId") groupId: string) {
return await this.groupsService.deleteGroup(groupId)
return await this.groupsService.deleteGroup(groupId);
}
//TODO Patch
@ -48,6 +48,11 @@ export class GroupsController {
@Query("search", new DefaultValuePipe("")) search: string,
@Param("groupId") groupId: string,
) {
return await this.groupsService.findFilesForGroup(limit, offset, search, groupId)
return await this.groupsService.findFilesForGroup(
limit,
offset,
search,
groupId,
);
}
}

View File

@ -1,7 +1,11 @@
import { Injectable, InternalServerErrorException, NotFoundException } from '@nestjs/common';
import {
Injectable,
InternalServerErrorException,
NotFoundException,
} from "@nestjs/common";
import { DbService } from "apps/backend/src/app/db/db.service";
import { FilesGroupTable, FilesTable } from 'apps/backend/src/app/db/schema';
import { and, eq, ilike } from 'drizzle-orm';
import { FilesGroupTable, FilesTable } from "apps/backend/src/app/db/schema";
import { and, eq, ilike } from "drizzle-orm";
@Injectable()
export class GroupsService {
@ -19,7 +23,6 @@ export class GroupsService {
.execute();
}
//TODO The method to create a group
async newGroup(groupName: string) {
return await this.database
.use()
@ -32,9 +35,9 @@ export class GroupsService {
.execute();
}
//TODO a method to delete a group and place the associated file at a null group reference
async deleteGroup(groupId: string) {
const groupInDb = await this.database.use()
const groupInDb = await this.database
.use()
.select()
.from(FilesGroupTable)
.where(eq(FilesGroupTable.uuid, groupId))
@ -54,8 +57,8 @@ export class GroupsService {
await this.database
.use()
.delete(FilesGroupTable)
.where(eq(FilesGroupTable.uuid, groupId))
return true
.where(eq(FilesGroupTable.uuid, groupId));
return true;
} catch (e) {
throw new InternalServerErrorException("Error while deleting group");
}
@ -71,10 +74,15 @@ export class GroupsService {
.use()
.select()
.from(FilesTable)
.where(and(eq(FilesTable.groupId, groupId), ilike(FilesTable.fileName, String(`%${searchField}%`)) ) )
.where(
and(
eq(FilesTable.groupId, groupId),
ilike(FilesTable.fileName, String(`%${searchField}%`)),
),
)
.limit(limit)
.offset(offset)
.prepare('findFilesInGroup')
.prepare("findFilesInGroup")
.execute();
}
}