From 1ec2b69f87e5f06e1f9a580bac2d73380988bcde Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Tue, 21 Nov 2023 09:24:46 +0700 Subject: [PATCH] refactor: route --- .../src/controllers/drawerController.ts | 10 +++---- Prototype/server/src/routes.ts | 26 +++++++++++++++++++ Prototype/server/src/swagger.json | 20 ++++++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/Prototype/server/src/controllers/drawerController.ts b/Prototype/server/src/controllers/drawerController.ts index 2100bc1..4bf9002 100644 --- a/Prototype/server/src/controllers/drawerController.ts +++ b/Prototype/server/src/controllers/drawerController.ts @@ -19,16 +19,16 @@ import HttpStatusCode from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; import { listFolder, pathExist } from "../utils/minio"; -@Route("/cabinet") +@Route("/cabinet/{cabinetName}/drawer") export class DrawerController extends Controller { - @Get("/{cabinetName}/drawer") + @Get("/") @Tags("Drawer") @SuccessResponse(HttpStatusCode.OK) public listDrawer(@Path() cabinetName: string) { return listFolder(`${cabinetName}/`); } - @Post("/{cabinetName}/drawer") + @Post("/") @Tags("Drawer") @Security("bearerAuth") @SuccessResponse(HttpStatusCode.CREATED) @@ -55,7 +55,7 @@ export class DrawerController extends Controller { return this.setStatus(HttpStatusCode.CREATED); } - @Put("/{cabinetName}/drawer/{drawerName}") + @Put("/{drawerName}") @Tags("Drawer") @Security("bearerAuth") @SuccessResponse(HttpStatusCode.NO_CONTENT) @@ -95,7 +95,7 @@ export class DrawerController extends Controller { }); } - @Delete("/{cabinetName}/drawer/{drawerName}") + @Delete("/{drawerName}") @Tags("Drawer") @Security("bearerAuth") @SuccessResponse(HttpStatusCode.NO_CONTENT) diff --git a/Prototype/server/src/routes.ts b/Prototype/server/src/routes.ts index 9184477..807727b 100644 --- a/Prototype/server/src/routes.ts +++ b/Prototype/server/src/routes.ts @@ -11,6 +11,8 @@ import { FileController } from './controllers/fileController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { FolderController } from './controllers/folderController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa +import { SearchController } from './controllers/searchController'; +// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { SubFolderController } from './controllers/subFolderController'; // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa import { SubFolderFileController } from './controllers/subFolderFileController'; @@ -515,6 +517,30 @@ export function RegisterRoutes(app: Router) { } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + app.post('/search', + ...(fetchMiddlewares(SearchController)), + ...(fetchMiddlewares(SearchController.prototype.searchFile)), + + function SearchController_searchFile(request: any, response: any, next: any) { + const args = { + }; + + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + + let validatedArgs: any[] = []; + try { + validatedArgs = getValidatedArgs(args, request, response); + + const controller = new SearchController(); + + + const promise = controller.searchFile.apply(controller, validatedArgs as any); + promiseHandler(controller, promise, response, 200, next); + } catch (err) { + return next(err); + } + }); + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.get('/cabinet/:cabinetName/drawer/:drawerName/folder/:folderName/subfolder', ...(fetchMiddlewares(SubFolderController)), ...(fetchMiddlewares(SubFolderController.prototype.listFolder)), diff --git a/Prototype/server/src/swagger.json b/Prototype/server/src/swagger.json index b1d98bc..ed1bf8f 100644 --- a/Prototype/server/src/swagger.json +++ b/Prototype/server/src/swagger.json @@ -919,6 +919,26 @@ ] } }, + "/search": { + "post": { + "operationId": "SearchFile", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "items": {}, + "type": "array" + } + } + } + } + }, + "security": [], + "parameters": [] + } + }, "/cabinet/{cabinetName}/drawer/{drawerName}/folder/{folderName}/subfolder": { "get": { "operationId": "ListFolder",