mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 18:28:12 +00:00
fix: Fixed wrong naming for error handler middleware
This commit is contained in:
+3
-2
@@ -29,8 +29,9 @@ import {
|
|||||||
integrationAuth as integrationAuthRouter
|
integrationAuth as integrationAuthRouter
|
||||||
} from './routes';
|
} from './routes';
|
||||||
import { getLogger } from './utils/logger';
|
import { getLogger } from './utils/logger';
|
||||||
import { catchUnroutedRequests } from './middleware/catchUnroutedRequests';
|
|
||||||
import { RouteNotFoundError } from './utils/errors';
|
import { RouteNotFoundError } from './utils/errors';
|
||||||
|
import { errorHandler } from '@sentry/node/types/handlers';
|
||||||
|
import { requestErrorHandler } from './middleware/requestErrorHandler';
|
||||||
|
|
||||||
export const app = express();
|
export const app = express();
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ app.use((req, res, next)=>{
|
|||||||
})
|
})
|
||||||
|
|
||||||
//* Error Handling Middleware (must be after all routing logic)
|
//* Error Handling Middleware (must be after all routing logic)
|
||||||
app.use(catchUnroutedRequests)
|
app.use(requestErrorHandler)
|
||||||
|
|
||||||
|
|
||||||
export const server = app.listen(PORT, () => {
|
export const server = app.listen(PORT, () => {
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import { getLogger } from "../utils/logger";
|
|||||||
import RequestError, { LogLevel } from "../utils/requestError";
|
import RequestError, { LogLevel } from "../utils/requestError";
|
||||||
|
|
||||||
|
|
||||||
export const catchUnroutedRequests: ErrorRequestHandler = (error: RequestError|Error, req, res, next) => {
|
export const requestErrorHandler: ErrorRequestHandler = (error: RequestError|Error, req, res, next) => {
|
||||||
if(res.headersSent) return next();
|
if(res.headersSent) return next();
|
||||||
//TODO: Find better way to type check for error. In current setting you need to cast type to get the functions and variables from RequestError
|
//TODO: Find better way to type check for error. In current setting you need to cast type to get the functions and variables from RequestError
|
||||||
if(!(error instanceof RequestError)){
|
if(!(error instanceof RequestError)){
|
||||||
Reference in New Issue
Block a user