-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lint-errors): fix linting errors
-fix linting errors by making appropriate changes [Fixes #34]
- Loading branch information
Showing
8 changed files
with
50 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
import { Request, Response, NextFunction } from 'express'; | ||
|
||
type MiddlewareFunction = (req: Request, res: Response, next: NextFunction) => Promise<void>; | ||
type MiddlewareFunction = ( | ||
req: Request, | ||
res: Response, | ||
next: NextFunction | ||
) => Promise<void>; | ||
|
||
function errorHandler(func: MiddlewareFunction) { | ||
return async (req: Request, res: Response, next: NextFunction) => { | ||
try { | ||
await func(req, res, next); | ||
} catch (error) { // Removed the type annotation from the catch clause variable because it caused liting errors | ||
const message = error.detail || 'Internal Server Error'; | ||
res.status(500).send(message); | ||
} | ||
}; | ||
} | ||
return async (req: Request, res: Response, next: NextFunction) => { | ||
try { | ||
await func(req, res, next); | ||
} catch (error) { | ||
// Removed the type annotation from the catch clause variable because it caused liting errors | ||
const message = error.detail || 'Internal Server Error'; | ||
res.status(500).send(message); | ||
} | ||
}; | ||
} | ||
|
||
export default errorHandler; | ||
export default errorHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
|
||
// router.use('/roles', roleRoutes) | ||
|
||
// export default router | ||
// export default router |