Compare commits
5 Commits
ec8af843b5
...
e931822010
Author | SHA1 | Date | |
---|---|---|---|
e931822010 | |||
d3feeb6d6a | |||
fd1742e9dc | |||
392446fa06 | |||
f72b7ad9cb |
@ -77,24 +77,30 @@ export class FilesController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log("Executing save procedure...");
|
console.log("Executing save procedure...");
|
||||||
return res
|
return (
|
||||||
|
res
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
.status(HttpStatus.CREATED)
|
.status(HttpStatus.CREATED)
|
||||||
.send(await this.filesService.save(fileBuffer, Params));
|
.send(await this.filesService.save(fileBuffer, Params))
|
||||||
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
return res
|
return (
|
||||||
|
res
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
.status(err.status || HttpStatus.INTERNAL_SERVER_ERROR)
|
.status(err.status || HttpStatus.INTERNAL_SERVER_ERROR)
|
||||||
.send(err);
|
.send(err)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
req.on("error", (err) => {
|
req.on("error", (err) => {
|
||||||
return res
|
return (
|
||||||
|
res
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
.status(err.status || HttpStatus.INTERNAL_SERVER_ERROR)
|
.status(err.status || HttpStatus.INTERNAL_SERVER_ERROR)
|
||||||
.send(err);
|
.send(err)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -107,7 +113,7 @@ export class FilesController {
|
|||||||
@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,
|
||||||
) {
|
) {
|
||||||
return this.filesService.search(limit, offset, search)
|
return this.filesService.search(limit, offset, search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@HttpCode(HttpStatus.FOUND)
|
@HttpCode(HttpStatus.FOUND)
|
||||||
|
@ -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 };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,38 +4,41 @@ import {
|
|||||||
Delete,
|
Delete,
|
||||||
Get,
|
Get,
|
||||||
Param,
|
Param,
|
||||||
|
ParseBoolPipe,
|
||||||
ParseIntPipe,
|
ParseIntPipe,
|
||||||
Post,
|
Post,
|
||||||
Query,
|
Query,
|
||||||
|
UseGuards,
|
||||||
} from "@nestjs/common";
|
} from "@nestjs/common";
|
||||||
|
import { AdminGuard } from "apps/backend/src/app/auth/auth.guard";
|
||||||
import { MachinesService } from "apps/backend/src/app/machines/machines.service";
|
import { MachinesService } from "apps/backend/src/app/machines/machines.service";
|
||||||
|
|
||||||
@Controller("machines")
|
@Controller("machines")
|
||||||
export class MachinesController {
|
export class MachinesController {
|
||||||
constructor(private readonly machineService: MachinesService) {}
|
constructor(private readonly machineService: MachinesService) {}
|
||||||
|
|
||||||
@Get()
|
@Get("find")
|
||||||
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,
|
||||||
) {
|
) {}
|
||||||
const query = { limit, offset, search };
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@UseGuards(AdminGuard)
|
||||||
@Post("new")
|
@Post("new")
|
||||||
async newMachine() {}
|
async newMachine() {}
|
||||||
|
|
||||||
|
@UseGuards(AdminGuard)
|
||||||
@Delete(":machineId")
|
@Delete(":machineId")
|
||||||
async deleteGroup(@Param("machineId") machineId: string) {}
|
async deleteMachine(@Param("machineId") machineId: string) {}
|
||||||
|
|
||||||
@Get(":groupId")
|
//TODO Patch
|
||||||
async getForGroup(
|
|
||||||
|
@Get(":machineId/files")
|
||||||
|
async getFilesForMachine(
|
||||||
@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("machineId") machineId: string,
|
@Param("machineId") machineId: string,
|
||||||
) {
|
) {}
|
||||||
const query = { limit, offset, search };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,10 @@ import { Module } from "@nestjs/common";
|
|||||||
import { DbModule } from "apps/backend/src/app/db/db.module";
|
import { DbModule } from "apps/backend/src/app/db/db.module";
|
||||||
import { MachinesController } from "apps/backend/src/app/machines/machines.controller";
|
import { MachinesController } from "apps/backend/src/app/machines/machines.controller";
|
||||||
import { MachinesService } from "apps/backend/src/app/machines/machines.service";
|
import { MachinesService } from "apps/backend/src/app/machines/machines.service";
|
||||||
|
import { CredentialsModule } from 'apps/backend/src/app/credentials/credentials.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [DbModule],
|
imports: [DbModule, CredentialsModule],
|
||||||
controllers: [MachinesController],
|
controllers: [MachinesController],
|
||||||
providers: [MachinesService],
|
providers: [MachinesService],
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user