WIP
This commit is contained in:
parent
efc7ad1efb
commit
fafd81db04
@ -1,49 +1,18 @@
|
|||||||
import { type Response, type Request } from "express";
|
import { type Response, type Request } from "express";
|
||||||
import { Controller, Get } from "@ControllerPattern/index";
|
import { Controller, Get } from "@ControllerPattern/index";
|
||||||
import { Service } from "typedi";
|
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";
|
import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||||
|
|
||||||
class Params {
|
|
||||||
@IsString()
|
|
||||||
@IsNotEmpty()
|
|
||||||
@IsUUID()
|
|
||||||
public uuid!: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Controller()
|
@Controller()
|
||||||
@Service()
|
@Service()
|
||||||
export default class ProjectController extends ApiController {
|
export default class ProjectController extends ApiController {
|
||||||
constructor(private projectService: ProjectService) {
|
|
||||||
super();
|
@Get("/api/projects/users")
|
||||||
}
|
|
||||||
|
|
||||||
@Get("/api/projects")
|
|
||||||
protected async get(req: Request, res: Response) {
|
protected async get(req: Request, res: Response) {
|
||||||
|
|
||||||
// const query = processFindManyQuery(req.query);
|
// const query = processFindManyQuery(req.query);
|
||||||
this.httpSuccess(res, { message: "get" });
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user