From 0e1d5f0bf8916f1e127798c635a6ce9b3336e60a Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:49:02 +0700 Subject: [PATCH 1/3] refactor(utils): merge 2 statement of same conditions --- src/interfaces/utils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts index ef23c9b1..d9edd9d9 100644 --- a/src/interfaces/utils.ts +++ b/src/interfaces/utils.ts @@ -5,8 +5,10 @@ export function calculateAge(start: Date, end = new Date()) { let month = end.getMonth() - start.getMonth(); let day = end.getDate() - start.getDate(); - if (month < 0) year -= 1; - if (month < 0) month += 12; + if (month < 0) { + month += 12; + year -= 1; + } if (day < 0) { month -= 1; day = From f47601a356fa5a3ceafb65aa05211055ccf6a8ab Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Mon, 11 Mar 2024 12:04:25 +0700 Subject: [PATCH 2/3] refactor(middlewares): add type to function parameter auth role --- src/middlewares/role.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middlewares/role.ts b/src/middlewares/role.ts index fef95919..681dc99b 100644 --- a/src/middlewares/role.ts +++ b/src/middlewares/role.ts @@ -5,7 +5,7 @@ import { RequestWithUser } from "./user"; export function authRole( role: string | string[], - errorMessage = "คุณไม่มีสิทธิในการเข้าถึงทรัพยากรดังกล่าว", + errorMessage: string = "คุณไม่มีสิทธิในการเข้าถึงทรัพยากรดังกล่าว", ) { return (req: RequestWithUser, _res: express.Response, next: express.NextFunction) => { if ((Array.isArray(role) && role.includes("*")) || role === "*") return next(); From 339ee19c3d763ec04a4f4fdb7136641970f8fc3b Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:18:08 +0700 Subject: [PATCH 3/3] chore(tsoa-setting): update to recursive path --- tsoa.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsoa.json b/tsoa.json index 588162ec..87fa35f9 100644 --- a/tsoa.json +++ b/tsoa.json @@ -1,7 +1,7 @@ { "entryFile": "src/app.ts", "noImplicitAdditionalProperties": "throw-on-extras", - "controllerPathGlobs": ["src/controllers/*Controller.ts"], + "controllerPathGlobs": ["src/controllers/**/*Controller.ts"], "spec": { "outputDirectory": "src", "specVersion": 3,