Skip to content

Commit

Permalink
Remove unnecessary middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
0417taehyun committed Dec 4, 2024
1 parent 978faa7 commit 7b1c963
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 20 deletions.
4 changes: 0 additions & 4 deletions src/lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,6 @@ export default async function getApp(
// Setup API routes
app.use(`${baseUriPath}/`, new IndexRouter(config, services, db).router);

if (services.openApiService) {
services.openApiService.useErrorHandler(app);
}

if (process.env.NODE_ENV !== 'production') {
app.use(errorHandler());
} else {
Expand Down
16 changes: 0 additions & 16 deletions src/lib/services/openapi-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type { ApiOperation } from '../openapi/util/api-operation';
import type { Logger } from '../logger';
import { validateSchema } from '../openapi/validate';
import type { IFlagResolver } from '../types';
import { fromOpenApiValidationErrors } from '../error/bad-data-error';

export class OpenApiService {
private readonly config: IUnleashConfig;
Expand Down Expand Up @@ -60,21 +59,6 @@ export class OpenApiService {
});
}

useErrorHandler(app: Express): void {
app.use((err, req, res, next) => {
if (err?.status && err.validationErrors) {
const apiError = fromOpenApiValidationErrors(
req,
err.validationErrors,
);

res.status(apiError.statusCode).json(apiError);
} else {
next(err);
}
});
}

respondWithValidation<T, S = SchemaId>(
status: number,
res: Response<T>,
Expand Down

0 comments on commit 7b1c963

Please sign in to comment.