From fbef4654d0f0f2f4e0f16997d60167390aaad964 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 11 Feb 2024 19:12:57 +0000 Subject: [PATCH 1/2] chore(deps): update dependency @myrotvorets/express-microservice-middlewares to v3 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7145c11d..2c4dd446 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@cloudnative/health-connect": "^2.1.0", "@myrotvorets/express-async-middleware-wrapper": "^2.2.0", - "@myrotvorets/express-microservice-middlewares": "^2.2.0", + "@myrotvorets/express-microservice-middlewares": "^3.0.0", "@myrotvorets/express-request-logger": "^1.2.1", "@myrotvorets/oav-installer": "^5.0.0", "@myrotvorets/opentelemetry-configurator": "^7.5.0", @@ -499,9 +499,9 @@ } }, "node_modules/@myrotvorets/express-microservice-middlewares": { - "version": "2.2.0", - "resolved": "https://npm.pkg.github.com/download/@myrotvorets/express-microservice-middlewares/2.2.0/a493ead0addc101326e81ed7acc5415ca384bddc", - "integrity": "sha512-m4WNW4DwqfR0oJAlKhd4gPcQhjIZ26t0lYTQhv87azSIR4Ia3P1kaLcCbrRgkUfxZ0tjEbb+KsbP651qzz/rpw==", + "version": "3.0.0", + "resolved": "https://npm.pkg.github.com/download/@myrotvorets/express-microservice-middlewares/3.0.0/f20d8bfd1b16ccbd98efe15f02de8b4dd688fa36", + "integrity": "sha512-E2c6yYikpYDZK//0hR6M6xmRvpVOFx2WLlnd6LMycNG60OfD0qAb2vYIL//EM1vwKhSSOARq07LUrBCNEcGw7Q==", "peerDependencies": { "express": "^4.0.0", "express-openapi-validator": "^3.0.0 || ^4.0.0 || ^5.0.0" diff --git a/package.json b/package.json index 5a630cae..5255665c 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "dependencies": { "@cloudnative/health-connect": "^2.1.0", "@myrotvorets/express-async-middleware-wrapper": "^2.2.0", - "@myrotvorets/express-microservice-middlewares": "^2.2.0", + "@myrotvorets/express-microservice-middlewares": "^3.0.0", "@myrotvorets/express-request-logger": "^1.2.1", "@myrotvorets/oav-installer": "^5.0.0", "@myrotvorets/opentelemetry-configurator": "^7.5.0", From f57c13561b29912d93610dfb123e48e92870a432 Mon Sep 17 00:00:00 2001 From: Myrotvorets Date: Mon, 19 Feb 2024 02:57:38 +0200 Subject: [PATCH 2/2] Update code --- src/controllers/search.mts | 8 ++------ src/server.mts | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/controllers/search.mts b/src/controllers/search.mts index a616bb50..a2a69393 100644 --- a/src/controllers/search.mts +++ b/src/controllers/search.mts @@ -1,5 +1,6 @@ import { type NextFunction, type Request, type Response, Router } from 'express'; import { asyncWrapperMiddleware } from '@myrotvorets/express-async-middleware-wrapper'; +import { ApiError } from '@myrotvorets/express-microservice-middlewares'; import type { SearchItem } from '../services/searchservice.mjs'; import { LocalsWithContainer } from '../lib/container.mjs'; @@ -22,12 +23,7 @@ async function searchHandler( const service = res.locals.container.resolve('searchService'); const result = await service.search(req.query.s); if (result === null) { - next({ - success: false, - status: 400, - code: 'BAD_SEARCH_TERM', - message: 'Both surname and name are required', - }); + next(new ApiError(400, 'BAD_SEARCH_TERM', 'Both surname and name are required')); } else { res.json({ success: true, diff --git a/src/server.mts b/src/server.mts index a4ef533d..c821b06b 100644 --- a/src/server.mts +++ b/src/server.mts @@ -27,7 +27,7 @@ export function configureApp(app: Express): ReturnType