@lucaapp/service-utils 1.64.0 → 1.65.0
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.
- package/dist/lib/api/api.js +8 -2
- package/dist/lib/api/endpoint.js +6 -0
- package/dist/lib/api/types/middleware.d.ts +2 -0
- package/dist/lib/kafka/events/operator.d.ts +1 -0
- package/dist/lib/kafka/events/paymentSyncError.d.ts +6 -0
- package/dist/lib/kafka/events/paymentSyncError.js +2 -0
- package/dist/lib/kafka/events.d.ts +4 -0
- package/dist/lib/kafka/events.js +2 -0
- package/dist/lib/logger/index.js +2 -0
- package/dist/lib/serviceIdentity/service.d.ts +2 -1
- package/dist/lib/serviceIdentity/service.js +1 -0
- package/package.json +5 -4
package/dist/lib/api/api.js
CHANGED
|
@@ -10,6 +10,13 @@ const swagger_ui_express_1 = __importDefault(require("swagger-ui-express"));
|
|
|
10
10
|
const zod_to_openapi_1 = require("@asteasolutions/zod-to-openapi");
|
|
11
11
|
const endpoint_1 = require("./endpoint");
|
|
12
12
|
const openapi_1 = require("./openapi");
|
|
13
|
+
const body_parser_1 = __importDefault(require("body-parser"));
|
|
14
|
+
const rawBodySaver = function (req, res, buf, encoding) {
|
|
15
|
+
if (buf && buf.length) {
|
|
16
|
+
// @ts-expect-error - rawBody is an extension
|
|
17
|
+
req.rawBody = buf.toString(encoding || 'utf8');
|
|
18
|
+
}
|
|
19
|
+
};
|
|
13
20
|
class Api {
|
|
14
21
|
constructor(options = {}) {
|
|
15
22
|
this.router = options.router || (0, express_1.Router)();
|
|
@@ -21,8 +28,7 @@ class Api {
|
|
|
21
28
|
this.apiDescription = options.apiDescription || '';
|
|
22
29
|
this.debug = options.debug || false;
|
|
23
30
|
this.tags = options.tags || [];
|
|
24
|
-
|
|
25
|
-
this.router.use((0, express_1.json)());
|
|
31
|
+
this.router.use(body_parser_1.default.json({ verify: rawBodySaver }));
|
|
26
32
|
}
|
|
27
33
|
child(options) {
|
|
28
34
|
return new Api({
|
package/dist/lib/api/endpoint.js
CHANGED
|
@@ -281,9 +281,15 @@ new Promise(async (resolve) => {
|
|
|
281
281
|
request.headers['content-type']?.includes('multipart/form-data')) {
|
|
282
282
|
files = await handleMultipleFileUpload(request);
|
|
283
283
|
}
|
|
284
|
+
let rawBody;
|
|
285
|
+
if (middleware.options.config?.returnRawBody) {
|
|
286
|
+
// @ts-expect-error - rawBody is an extension
|
|
287
|
+
rawBody = request.rawBody;
|
|
288
|
+
}
|
|
284
289
|
// if the header is multipart we should return a buffer with the content
|
|
285
290
|
const handlerRequest = {
|
|
286
291
|
body: handlerRequestBody,
|
|
292
|
+
...(rawBody && { rawBody }),
|
|
287
293
|
...(file && { file }),
|
|
288
294
|
...(files && { files }),
|
|
289
295
|
params: handlerRequestParams,
|
|
@@ -18,6 +18,7 @@ export type FileUpload = {
|
|
|
18
18
|
};
|
|
19
19
|
export type MiddlewareHandler<TResponseSchema, TRequestBodySchema, TRequestParamsSchema, TRequestQuerySchema, TRequestHeadersSchema, TContextSchema> = (request: {
|
|
20
20
|
body: ZodSchemaOuput<TRequestBodySchema>;
|
|
21
|
+
rawBody?: string | Buffer | object;
|
|
21
22
|
params: ZodSchemaOuput<TRequestParamsSchema>;
|
|
22
23
|
query: ZodSchemaOuput<TRequestQuerySchema>;
|
|
23
24
|
headers: ZodSchemaOuput<TRequestHeadersSchema>;
|
|
@@ -41,6 +42,7 @@ export type MiddlewareOptions<TResponseSchemas extends ReadonlyArray<EndpointRes
|
|
|
41
42
|
config?: {
|
|
42
43
|
isFileUpload?: boolean;
|
|
43
44
|
isFilesUpload?: boolean;
|
|
45
|
+
returnRawBody?: boolean;
|
|
44
46
|
};
|
|
45
47
|
errors?: Record<string, number>;
|
|
46
48
|
};
|
|
@@ -11,6 +11,7 @@ import { Reservation } from './events/reservation';
|
|
|
11
11
|
import { ReservationPrePayment } from './events/reservationPrePayment';
|
|
12
12
|
import { ConsumerPushNotification } from './events/consumerPushNotification';
|
|
13
13
|
import { OperatorLocationGroup } from '../../types/operatorLocationGroup';
|
|
14
|
+
import { PaymentSyncError } from './events/paymentSyncError';
|
|
14
15
|
declare enum KafkaTopic {
|
|
15
16
|
PAYMENTS = "payments",
|
|
16
17
|
CONSUMERS = "consumers",
|
|
@@ -23,6 +24,7 @@ declare enum KafkaTopic {
|
|
|
23
24
|
RESERVATION_FEES = "reservation_fees",
|
|
24
25
|
RESERVATION_PRE_PAYMENT = "reservation_pre_payment",
|
|
25
26
|
CONSUMER_PUSH_NOTIFICATION = "consumer_push_notifications",
|
|
27
|
+
PAYMENT_SYNC_ERRORS = "payment_sync_errors",
|
|
26
28
|
WS_EVENT_backend = "wsevent_backend",
|
|
27
29
|
WS_EVENT_backend_pay = "wsevent_backend-pay",
|
|
28
30
|
WS_EVENT_backend_pos = "wsevent_backend-pos"
|
|
@@ -39,6 +41,7 @@ type MessageFormats = {
|
|
|
39
41
|
[KafkaTopic.RESERVATION_FEES]: ReservationFee;
|
|
40
42
|
[KafkaTopic.RESERVATION_PRE_PAYMENT]: ReservationPrePayment;
|
|
41
43
|
[KafkaTopic.CONSUMER_PUSH_NOTIFICATION]: ConsumerPushNotification;
|
|
44
|
+
[KafkaTopic.PAYMENT_SYNC_ERRORS]: PaymentSyncError;
|
|
42
45
|
[KafkaTopic.WS_EVENT_backend]: WsEvent;
|
|
43
46
|
[KafkaTopic.WS_EVENT_backend_pay]: WsEvent;
|
|
44
47
|
[KafkaTopic.WS_EVENT_backend_pos]: WsEvent;
|
|
@@ -55,6 +58,7 @@ declare const MessageIssuer: {
|
|
|
55
58
|
reservation_fees: Service;
|
|
56
59
|
reservation_pre_payment: Service;
|
|
57
60
|
consumer_push_notifications: Service;
|
|
61
|
+
payment_sync_errors: Service;
|
|
58
62
|
wsevent_backend: Service;
|
|
59
63
|
"wsevent_backend-pay": Service;
|
|
60
64
|
"wsevent_backend-pos": Service;
|
package/dist/lib/kafka/events.js
CHANGED
|
@@ -15,6 +15,7 @@ var KafkaTopic;
|
|
|
15
15
|
KafkaTopic["RESERVATION_FEES"] = "reservation_fees";
|
|
16
16
|
KafkaTopic["RESERVATION_PRE_PAYMENT"] = "reservation_pre_payment";
|
|
17
17
|
KafkaTopic["CONSUMER_PUSH_NOTIFICATION"] = "consumer_push_notifications";
|
|
18
|
+
KafkaTopic["PAYMENT_SYNC_ERRORS"] = "payment_sync_errors";
|
|
18
19
|
KafkaTopic["WS_EVENT_backend"] = "wsevent_backend";
|
|
19
20
|
KafkaTopic["WS_EVENT_backend_pay"] = "wsevent_backend-pay";
|
|
20
21
|
KafkaTopic["WS_EVENT_backend_pos"] = "wsevent_backend-pos";
|
|
@@ -31,6 +32,7 @@ const MessageIssuer = {
|
|
|
31
32
|
[KafkaTopic.RESERVATION_FEES]: serviceIdentity_1.Service.BACKEND_PAY,
|
|
32
33
|
[KafkaTopic.RESERVATION_PRE_PAYMENT]: serviceIdentity_1.Service.BACKEND_PAY,
|
|
33
34
|
[KafkaTopic.CONSUMER_PUSH_NOTIFICATION]: serviceIdentity_1.Service.BACKEND,
|
|
35
|
+
[KafkaTopic.PAYMENT_SYNC_ERRORS]: serviceIdentity_1.Service.BACKEND_POS,
|
|
34
36
|
[KafkaTopic.WS_EVENT_backend]: serviceIdentity_1.Service.BACKEND,
|
|
35
37
|
[KafkaTopic.WS_EVENT_backend_pay]: serviceIdentity_1.Service.BACKEND_PAY,
|
|
36
38
|
[KafkaTopic.WS_EVENT_backend_pos]: serviceIdentity_1.Service.BACKEND_POS,
|
package/dist/lib/logger/index.js
CHANGED
|
@@ -22,6 +22,7 @@ class LoggerFactory {
|
|
|
22
22
|
{
|
|
23
23
|
target: 'pino/file',
|
|
24
24
|
options: { destination: 1 },
|
|
25
|
+
level: logLevel,
|
|
25
26
|
},
|
|
26
27
|
...(sentryDsn
|
|
27
28
|
? [
|
|
@@ -38,6 +39,7 @@ class LoggerFactory {
|
|
|
38
39
|
context: ['reqId'],
|
|
39
40
|
minLevel: minLevel ?? 50,
|
|
40
41
|
},
|
|
42
|
+
level: logLevel,
|
|
41
43
|
},
|
|
42
44
|
]
|
|
43
45
|
: []),
|
|
@@ -6,6 +6,7 @@ declare enum Service {
|
|
|
6
6
|
BACKEND_ATTESTATION = "backend-attestation",
|
|
7
7
|
BACKEND_PUBSUB = "backend-pubsub",
|
|
8
8
|
BACKEND_AI = "backend-ai",
|
|
9
|
-
BACKEND_PYTHON = "backend-python"
|
|
9
|
+
BACKEND_PYTHON = "backend-python",
|
|
10
|
+
BACKEND_LINK = "backend-link"
|
|
10
11
|
}
|
|
11
12
|
export { Service };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucaapp/service-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.65.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
"audit": "improved-yarn-audit --ignore-dev-deps"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
+
"@apidevtools/swagger-parser": "10.0.3",
|
|
21
22
|
"@asteasolutions/zod-to-openapi": "6.1.0",
|
|
22
|
-
"@hapi/boom": "^10.0.
|
|
23
|
+
"@hapi/boom": "^10.0.1",
|
|
23
24
|
"@sentry/node": "^9.10.1",
|
|
24
25
|
"@tsconfig/node22": "22.0.0",
|
|
25
26
|
"@types/express": "4.17.15",
|
|
@@ -28,6 +29,7 @@
|
|
|
28
29
|
"@types/response-time": "^2.3.8",
|
|
29
30
|
"@types/swagger-ui-express": "4.1.3",
|
|
30
31
|
"axios": "^1.8.2",
|
|
32
|
+
"body-parser": "^2.2.0",
|
|
31
33
|
"busboy": "^1.6.0",
|
|
32
34
|
"cls-rtracer": "^2.6.2",
|
|
33
35
|
"express": "4.21.2",
|
|
@@ -47,8 +49,7 @@
|
|
|
47
49
|
"swagger-ui-express": "5.0.1",
|
|
48
50
|
"url-value-parser": "^2.2.0",
|
|
49
51
|
"uuid": "^9.0.0",
|
|
50
|
-
"zod": "3.22.3"
|
|
51
|
-
"@apidevtools/swagger-parser": "10.0.3"
|
|
52
|
+
"zod": "3.22.3"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@types/busboy": "^1.5.4",
|