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 FoldersService from "@Services/FoldersService/FoldersService";
|
|
import { Service } from "typedi";
|
|
// import { IsNotEmpty, IsString, IsUUID } from "class-validator";
|
|
|
|
// class Params {
|
|
// @IsString()
|
|
// @IsNotEmpty()
|
|
// @IsUUID()
|
|
// public uuid!: string;
|
|
// }
|
|
|
|
@Controller()
|
|
@Service()
|
|
export default class FolderController extends ApiController {
|
|
constructor(private foldersService: FoldersService) {
|
|
super();
|
|
}
|
|
|
|
/**
|
|
* @description Get all folders
|
|
* @returns IFolder[] list of folders
|
|
*/
|
|
@Get("/api/folders")
|
|
protected async get(req: Request, response: Response) {
|
|
try {
|
|
// TODO
|
|
} catch (error) {
|
|
this.httpBadRequest(response, error);
|
|
return;
|
|
}
|
|
this.httpSuccess(response, await this.foldersService.get());
|
|
}
|
|
|
|
/**
|
|
* @description Create a new folder
|
|
* @returns IFolder created
|
|
*/
|
|
@Post("/api/folders")
|
|
protected async post(req: Request, response: Response) {
|
|
try {
|
|
// TODO
|
|
} catch (error) {
|
|
this.httpBadRequest(response, error);
|
|
return;
|
|
}
|
|
this.httpSuccess(response, await this.foldersService.create());
|
|
}
|
|
|
|
/**
|
|
* @description Modify a specific folder by uid
|
|
* @returns IFolder modified
|
|
*/
|
|
@Put("/api/folders/:uid")
|
|
protected async put(req: Request, response: Response) {
|
|
try {
|
|
// TODO
|
|
} catch (error) {
|
|
this.httpBadRequest(response, error);
|
|
return;
|
|
}
|
|
this.httpSuccess(response, await this.foldersService.put());
|
|
}
|
|
|
|
/**
|
|
* @description Get a specific folder by uid
|
|
* @returns IFolder
|
|
*/
|
|
@Get("/api/folders/:uid")
|
|
protected async getOneByUid(req: Request, response: Response) {
|
|
try {
|
|
// TODO
|
|
} catch (error) {
|
|
this.httpBadRequest(response, error);
|
|
return;
|
|
}
|
|
this.httpSuccess(response, await this.foldersService.getByUid("uid"));
|
|
}
|
|
}
|