@unito/integration-sdk 0.1.4 → 0.1.5
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/src/handler.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ type WebhookSubscriptionHandlers = {
|
|
|
54
54
|
updateWebhookSubscriptions: UpdateWebhookSubscriptionsHandler;
|
|
55
55
|
};
|
|
56
56
|
type AcknowledgeWebhookHandlers = {
|
|
57
|
-
acknowledgeWebhooks
|
|
57
|
+
acknowledgeWebhooks: AckknowledgeWebhooksHandler;
|
|
58
58
|
};
|
|
59
59
|
export type HandlersInput = ItemHandlers | CredentialAccountHandlers | ParseWebhookHandlers | WebhookSubscriptionHandlers | AcknowledgeWebhookHandlers;
|
|
60
60
|
export declare class Handler {
|
|
@@ -6,11 +6,11 @@ const middleware = (req, res, next) => {
|
|
|
6
6
|
const rawAdditionalContext = req.header(ADDITIONAL_CONTEXT_HEADER);
|
|
7
7
|
if (typeof rawAdditionalContext === 'string') {
|
|
8
8
|
try {
|
|
9
|
-
const additionalContext = JSON.parse(
|
|
9
|
+
const additionalContext = JSON.parse(rawAdditionalContext);
|
|
10
10
|
logger.decorate(additionalContext);
|
|
11
11
|
}
|
|
12
12
|
catch (error) {
|
|
13
|
-
logger.warn(`
|
|
13
|
+
logger.warn(`Failed parsing header ${ADDITIONAL_CONTEXT_HEADER}: ${rawAdditionalContext}`);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
next();
|
|
@@ -19,9 +19,9 @@ describe('logger middleware', () => {
|
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
21
|
it('additional context', () => {
|
|
22
|
-
const additional =
|
|
22
|
+
const additional = JSON.stringify({
|
|
23
23
|
foo: 'bar',
|
|
24
|
-
})
|
|
24
|
+
});
|
|
25
25
|
const request = { header: (_key) => additional };
|
|
26
26
|
const response = { locals: { correlationId: '123' } };
|
|
27
27
|
middleware(request, response, () => { });
|
package/package.json
CHANGED
package/src/handler.ts
CHANGED
|
@@ -22,11 +22,11 @@ const middleware = (req: Request, res: Response, next: NextFunction) => {
|
|
|
22
22
|
|
|
23
23
|
if (typeof rawAdditionalContext === 'string') {
|
|
24
24
|
try {
|
|
25
|
-
const additionalContext = JSON.parse(
|
|
25
|
+
const additionalContext = JSON.parse(rawAdditionalContext);
|
|
26
26
|
|
|
27
27
|
logger.decorate(additionalContext);
|
|
28
28
|
} catch (error) {
|
|
29
|
-
logger.warn(`
|
|
29
|
+
logger.warn(`Failed parsing header ${ADDITIONAL_CONTEXT_HEADER}: ${rawAdditionalContext}`);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -27,11 +27,9 @@ describe('logger middleware', () => {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
it('additional context', () => {
|
|
30
|
-
const additional =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}),
|
|
34
|
-
).toString('base64');
|
|
30
|
+
const additional = JSON.stringify({
|
|
31
|
+
foo: 'bar',
|
|
32
|
+
});
|
|
35
33
|
|
|
36
34
|
const request = { header: (_key: string) => additional } as express.Request;
|
|
37
35
|
const response = { locals: { correlationId: '123' } } as express.Response;
|