82 lines
1.9 KiB
TypeScript
82 lines
1.9 KiB
TypeScript
import { type Response, type Request } from "express";
|
|
import { Controller, Get, Post, Put } from "@ControllerPattern/index";
|
|
import ApiController from "@Common/system/controller-pattern/ApiController";
|
|
import DeedsService from "@Services/DeedsService/DeedsService";
|
|
import { Service } from "typedi";
|
|
// import { IsNotEmpty, IsString, IsUUID } from "class-validator";
|
|
|
|
// class Params {
|
|
// @IsString()
|
|
// @IsNotEmpty()
|
|
// @IsUUID()
|
|
// public uuid!: string;
|
|
// }
|
|
|
|
@Controller()
|
|
@Service()
|
|
export default class DeedsController extends ApiController {
|
|
constructor(private deedsService: DeedsService) {
|
|
super();
|
|
}
|
|
|
|
/**
|
|
* @description Get all deeds
|
|
* @returns IDeed[] list of deeds
|
|
*/
|
|
@Get("/api/deeds")
|
|
protected async get(req: Request, response: Response) {
|
|
try {
|
|
// TODO
|
|
} catch (error) {
|
|
this.httpBadRequest(response, error);
|
|
return;
|
|
}
|
|
this.httpSuccess(response, await this.deedsService.get());
|
|
}
|
|
|
|
/**
|
|
* @description Create a new deed
|
|
* @returns IDeed created
|
|
*/
|
|
@Post("/api/deeds")
|
|
protected async post(req: Request, response: Response) {
|
|
try {
|
|
// TODO
|
|
} catch (error) {
|
|
this.httpBadRequest(response, error);
|
|
return;
|
|
}
|
|
this.httpSuccess(response, await this.deedsService.create());
|
|
}
|
|
|
|
/**
|
|
* @description Modify a specific deed by uid
|
|
* @returns IDeed modified
|
|
*/
|
|
@Put("/api/deeds/:uid")
|
|
protected async put(req: Request, response: Response) {
|
|
try {
|
|
// TODO
|
|
} catch (error) {
|
|
this.httpBadRequest(response, error);
|
|
return;
|
|
}
|
|
this.httpSuccess(response, await this.deedsService.put());
|
|
}
|
|
|
|
/**
|
|
* @description Get a specific deed by uid
|
|
* @returns IDeed
|
|
*/
|
|
@Get("/api/deeds/:uid")
|
|
protected async getOneByUid(req: Request, response: Response) {
|
|
try {
|
|
// TODO
|
|
} catch (error) {
|
|
this.httpBadRequest(response, error);
|
|
return;
|
|
}
|
|
this.httpSuccess(response, await this.deedsService.getByUid("uid"));
|
|
}
|
|
}
|