This commit is contained in:
Vincent Alamelle 2023-03-17 10:35:36 +01:00
parent efc7ad1efb
commit fafd81db04

View File

@ -1,49 +1,18 @@
import { type Response, type Request } from "express";
import { Controller, Get } from "@ControllerPattern/index";
import { Service } from "typedi";
import { IsNotEmpty, IsString, IsUUID, validateOrReject } from "class-validator";
import ProjectService from "@Services/_TemplateService/_TemplateService";
import ApiController from "@Common/system/controller-pattern/ApiController";
class Params {
@IsString()
@IsNotEmpty()
@IsUUID()
public uuid!: string;
}
@Controller()
@Service()
export default class ProjectController extends ApiController {
constructor(private projectService: ProjectService) {
super();
}
@Get("/api/projects")
@Get("/api/projects/users")
protected async get(req: Request, res: Response) {
// const query = processFindManyQuery(req.query);
this.httpSuccess(res, { message: "get" });
}
@Get("/api/projects/:uuid")
protected async getByUUID(req: Request, res: Response) {
const { uuid } = req.params as Partial<Params>;
const params = new Params();
params.uuid = uuid!;
try {
await validateOrReject(params, { forbidUnknownValues: true });
} catch (error) {
this.httpBadRequest(res, error);
return;
}
const project = await this.projectService.getByUUID();
// if (!project) {
// this.httpNotFoundRequest(res);
// return;
// }
this.httpSuccess(res, project);
}
}