Commit e7bcc28f49e4eac79baaa98e8322a412f2fea2c0
1 parent
62fcc778ca
Exists in
master
Use await on calling axios at webhook-sender
Showing 3 changed files with 17 additions and 12 deletions Side-by-side Diff
lib/webhook-sender.js
... | ... | @@ -20,7 +20,7 @@ const baseDumpDir = path.join('dump', 'webhook-sender'); |
20 | 20 | if (!fs.existsSync(baseDumpDir)) { |
21 | 21 | fs.mkdirSync(baseDumpDir, { recursive: true }); |
22 | 22 | } |
23 | -const lastDumpFileName = path.join(baseDumpDir, 'last'); | |
23 | +const lastDumpFileName = path.join(baseDumpDir, 'last.json'); | |
24 | 24 | |
25 | 25 | const sleepMs = (ms) => new Promise((resolve) => { |
26 | 26 | setTimeout(() => { |
... | ... | @@ -34,8 +34,9 @@ const dumper = async (xid, webhookType, body) => { |
34 | 34 | } |
35 | 35 | |
36 | 36 | try { |
37 | + const filename = [moment().format('YYYYMMDD-HHmmssSSS'), xid].join('_'); | |
37 | 38 | await fs.promises.writeFile( |
38 | - path.join(baseDumpDir, [moment().format('YYYYMMDD-HHmmssSSS'), xid].join('_')), | |
39 | + path.join(baseDumpDir, `${filename}.json`), | |
39 | 40 | stringify({ webhookType, body }), |
40 | 41 | ); |
41 | 42 | |
... | ... | @@ -66,7 +67,7 @@ const sender = async (xid, webhookType, body, retry) => { |
66 | 67 | request_id: body.request_id, |
67 | 68 | }); |
68 | 69 | |
69 | - axios.post(config.listener.partner.webhook, { | |
70 | + await axios.post(config.listener.partner.webhook, { | |
70 | 71 | webhookType, |
71 | 72 | body, |
72 | 73 | }); |
package-lock.json
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | "version": "0.18.6", |
10 | 10 | "license": "ISC", |
11 | 11 | "dependencies": { |
12 | - "axios": "^1.7.2", | |
12 | + "axios": "^1.7.3", | |
13 | 13 | "express": "^4.17.1", |
14 | 14 | "express-rate-limit": "^6.6.0", |
15 | 15 | "join-path": "^1.1.1", |
... | ... | @@ -306,9 +306,10 @@ |
306 | 306 | "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" |
307 | 307 | }, |
308 | 308 | "node_modules/axios": { |
309 | - "version": "1.7.2", | |
310 | - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", | |
311 | - "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", | |
309 | + "version": "1.7.3", | |
310 | + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.3.tgz", | |
311 | + "integrity": "sha512-Ar7ND9pU99eJ9GpoGQKhKf58GpUOgnzuaB7ueNQ5BMi0p+LZ5oaEnfF999fAArcTIBwXTCHAmGcHOZJaWPq9Nw==", | |
312 | + "license": "MIT", | |
312 | 313 | "dependencies": { |
313 | 314 | "follow-redirects": "^1.15.6", |
314 | 315 | "form-data": "^4.0.0", |
... | ... | @@ -319,6 +320,7 @@ |
319 | 320 | "version": "4.0.0", |
320 | 321 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", |
321 | 322 | "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", |
323 | + "license": "MIT", | |
322 | 324 | "dependencies": { |
323 | 325 | "asynckit": "^0.4.0", |
324 | 326 | "combined-stream": "^1.0.8", |
... | ... | @@ -1467,6 +1469,7 @@ |
1467 | 1469 | "url": "https://github.com/sponsors/RubenVerborgh" |
1468 | 1470 | } |
1469 | 1471 | ], |
1472 | + "license": "MIT", | |
1470 | 1473 | "engines": { |
1471 | 1474 | "node": ">=4.0" |
1472 | 1475 | }, |
... | ... | @@ -3318,7 +3321,8 @@ |
3318 | 3321 | "node_modules/proxy-from-env": { |
3319 | 3322 | "version": "1.1.0", |
3320 | 3323 | "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", |
3321 | - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" | |
3324 | + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", | |
3325 | + "license": "MIT" | |
3322 | 3326 | }, |
3323 | 3327 | "node_modules/pseudomap": { |
3324 | 3328 | "version": "1.0.2", |
... | ... | @@ -4893,9 +4897,9 @@ |
4893 | 4897 | "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==" |
4894 | 4898 | }, |
4895 | 4899 | "axios": { |
4896 | - "version": "1.7.2", | |
4897 | - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", | |
4898 | - "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", | |
4900 | + "version": "1.7.3", | |
4901 | + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.3.tgz", | |
4902 | + "integrity": "sha512-Ar7ND9pU99eJ9GpoGQKhKf58GpUOgnzuaB7ueNQ5BMi0p+LZ5oaEnfF999fAArcTIBwXTCHAmGcHOZJaWPq9Nw==", | |
4899 | 4903 | "requires": { |
4900 | 4904 | "follow-redirects": "^1.15.6", |
4901 | 4905 | "form-data": "^4.0.0", |