@lucaapp/service-utils 1.53.0 → 1.53.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,7 @@ exports.mountEndpoint = void 0;
7
7
  const zod_1 = require("zod");
8
8
  const assert_1 = __importDefault(require("assert"));
9
9
  const http_1 = require("./types/http");
10
+ const libphonenumber_js_1 = require("libphonenumber-js");
10
11
  const sendBadContextError = (response, error, debug) => {
11
12
  response.err = error;
12
13
  return response.status(500).send({
@@ -37,7 +38,7 @@ const sendBadResponseError = (response, error, debug) => {
37
38
  }),
38
39
  });
39
40
  };
40
- const sendBadRequestError = (response, error) => {
41
+ const sendBadRequestZodError = (response, error) => {
41
42
  response.err = error;
42
43
  return response.status(400).send({
43
44
  error: http_1.HTTPStatus.BAD_REQUEST,
@@ -45,6 +46,13 @@ const sendBadRequestError = (response, error) => {
45
46
  issues: error.issues,
46
47
  });
47
48
  };
49
+ const sendBadRequestError = (response, error) => {
50
+ response.err = error;
51
+ return response.status(400).send({
52
+ error: http_1.HTTPStatus.BAD_REQUEST,
53
+ message: error.message,
54
+ });
55
+ };
48
56
  const sendKnownErrorResponse = (response, statusCode, error, debug) => {
49
57
  response.err = error;
50
58
  response.status(statusCode).send({
@@ -155,7 +163,7 @@ new Promise(async (resolve) => {
155
163
  }
156
164
  catch (error) {
157
165
  if (error instanceof zod_1.ZodError) {
158
- sendBadRequestError(response, error);
166
+ sendBadRequestZodError(response, error);
159
167
  return resolve(false);
160
168
  }
161
169
  throw error;
@@ -213,7 +221,11 @@ const mountEndpoint = (router, method, path, options, handler, debug) => {
213
221
  }
214
222
  catch (error) {
215
223
  if (error instanceof zod_1.ZodError) {
216
- return sendBadRequestError(response, error);
224
+ return sendBadRequestZodError(response, error);
225
+ }
226
+ if (error instanceof libphonenumber_js_1.ParseError) {
227
+ const newError = new Error(error.message);
228
+ return sendBadRequestError(response, newError);
217
229
  }
218
230
  throw error;
219
231
  }
@@ -1 +1,2 @@
1
1
  export * from './requestMetrics';
2
+ export * from './deprecatedEndpoint';
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./requestMetrics"), exports);
18
+ __exportStar(require("./deprecatedEndpoint"), exports);
@@ -4,6 +4,7 @@ declare enum Service {
4
4
  BACKEND_POS = "backend-pos",
5
5
  BACKEND_ID = "backend-id",
6
6
  BACKEND_ATTESTATION = "backend-attestation",
7
- BACKEND_PUBSUB = "backend-pubsub"
7
+ BACKEND_PUBSUB = "backend-pubsub",
8
+ BACKEND_AI = "backend-ai"
8
9
  }
9
10
  export { Service };
@@ -9,5 +9,6 @@ var Service;
9
9
  Service["BACKEND_ID"] = "backend-id";
10
10
  Service["BACKEND_ATTESTATION"] = "backend-attestation";
11
11
  Service["BACKEND_PUBSUB"] = "backend-pubsub";
12
+ Service["BACKEND_AI"] = "backend-ai";
12
13
  })(Service || (Service = {}));
13
14
  exports.Service = Service;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucaapp/service-utils",
3
- "version": "1.53.0",
3
+ "version": "1.53.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -32,6 +32,7 @@
32
32
  "express-async-errors": "3.1.1",
33
33
  "jose": "4.9.2",
34
34
  "kafkajs": "2.1.0",
35
+ "libphonenumber-js": "1.9.44",
35
36
  "lodash": "^4.17.21",
36
37
  "moment": "2.29.4",
37
38
  "moment-timezone": "^0.5.43",