Skip to content

Commit adeab1f

Browse files
committed
Replace requestID with requestId
This matches the case used by other FireFly connectors. Signed-off-by: Andrew Richardson <[email protected]>
1 parent 2e82ebc commit adeab1f

File tree

6 files changed

+33
-33
lines changed

6 files changed

+33
-33
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ This will make it possible for the organizations to establish MTLS communication
131131
| Type | Description | Additional properties
132132
|-----------------|------------------------------------------------------------|-----------------------
133133
|blob-received | Emitted to the recipient when a blob has been transferred | sender, path, hash
134-
|blob-delivered | Emitted to the sender when a blob has been delivered | recipient, path, requestID (optional)
135-
|blob-failed | Emitted to the sender when a blob could not be delivered | recipient, path, requestID (optional)
134+
|blob-delivered | Emitted to the sender when a blob has been delivered | recipient, path, requestId (optional)
135+
|blob-failed | Emitted to the sender when a blob could not be delivered | recipient, path, requestId (optional)
136136
|message-received | Emitted to the recipient when a message has been sent | sender, message
137-
|message-delivered| Emitted to the sender when a message has been delivered | recipient, message, requestID (optional)
138-
|message-failed | Emitted to the sender when a message could not be delivered| recipient, message, requestID (optional)
137+
|message-delivered| Emitted to the sender when a message has been delivered | recipient, message, requestId (optional)
138+
|message-failed | Emitted to the sender when a message could not be delivered| recipient, message, requestId (optional)
139139

140140
- After receiving a websocket message, a commit must be sent in order to receive the next one:
141141
```

src/handlers/blobs.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,20 @@ export const storeBlob = async (file: IFile, filePath: string) => {
6868
return await upsertMetadata(filePath, blobHash, blobSize);
6969
};
7070

71-
export const sendBlob = async (blobPath: string, recipient: string, recipientURL: string, requestID: string | undefined) => {
71+
export const sendBlob = async (blobPath: string, recipient: string, recipientURL: string, requestId: string | undefined) => {
7272
if (sending) {
73-
blobQueue.push({ blobPath, recipient, recipientURL, requestID });
73+
blobQueue.push({ blobPath, recipient, recipientURL, requestId });
7474
} else {
7575
sending = true;
76-
blobQueue.push({ blobPath, recipient, recipientURL, requestID });
76+
blobQueue.push({ blobPath, recipient, recipientURL, requestId });
7777
while (blobQueue.length > 0) {
7878
await deliverBlob(blobQueue.shift()!);
7979
}
8080
sending = false;
8181
}
8282
};
8383

84-
export const deliverBlob = async ({ blobPath, recipient, recipientURL, requestID }: BlobTask) => {
84+
export const deliverBlob = async ({ blobPath, recipient, recipientURL, requestId }: BlobTask) => {
8585
const resolvedFilePath = path.join(utils.constants.DATA_DIRECTORY, utils.constants.BLOBS_SUBDIRECTORY, blobPath);
8686
if (!(await utils.fileExists(resolvedFilePath))) {
8787
throw new RequestError('Blob not found', 404);
@@ -105,7 +105,7 @@ export const deliverBlob = async ({ blobPath, recipient, recipientURL, requestID
105105
type: 'blob-delivered',
106106
path: blobPath,
107107
recipient,
108-
requestID
108+
requestId
109109
} as IBlobDeliveredEvent);
110110
log.trace(`Blob delivered`);
111111
} catch (err: any) {
@@ -114,7 +114,7 @@ export const deliverBlob = async ({ blobPath, recipient, recipientURL, requestID
114114
type: 'blob-failed',
115115
path: blobPath,
116116
recipient,
117-
requestID,
117+
requestId,
118118
error: err.message,
119119
} as IBlobFailedEvent);
120120
log.error(`Failed to deliver blob ${err}`);

src/handlers/messages.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ let messageQueue: MessageTask[] = [];
2929
let sending = false;
3030
export const eventEmitter = new EventEmitter();
3131

32-
export const sendMessage = async (message: string, recipient: string, recipientURL: string, requestID: string | undefined) => {
32+
export const sendMessage = async (message: string, recipient: string, recipientURL: string, requestId: string | undefined) => {
3333
if (sending) {
34-
messageQueue.push({ message, recipient, recipientURL, requestID });
34+
messageQueue.push({ message, recipient, recipientURL, requestId });
3535
} else {
3636
sending = true;
37-
messageQueue.push({ message, recipient, recipientURL, requestID });
37+
messageQueue.push({ message, recipient, recipientURL, requestId });
3838
while (messageQueue.length > 0) {
3939
await deliverMessage(messageQueue.shift()!);
4040
}
4141
sending = false;
4242
}
4343
};
4444

45-
export const deliverMessage = async ({ message, recipient, recipientURL, requestID }: MessageTask) => {
45+
export const deliverMessage = async ({ message, recipient, recipientURL, requestId }: MessageTask) => {
4646
const httpsAgent = new https.Agent({ cert, key, ca });
4747
const formData = new FormData();
4848
formData.append('message', message);
@@ -60,7 +60,7 @@ export const deliverMessage = async ({ message, recipient, recipientURL, request
6060
type: 'message-delivered',
6161
message,
6262
recipient,
63-
requestID
63+
requestId
6464
} as IMessageDeliveredEvent);
6565
log.trace(`Message delivered`);
6666
} catch(err: any) {
@@ -69,7 +69,7 @@ export const deliverMessage = async ({ message, recipient, recipientURL, request
6969
type: 'message-failed',
7070
message,
7171
recipient,
72-
requestID,
72+
requestId,
7373
error: err.message,
7474
} as IMessageFailedEvent);
7575
log.error(`Failed to deliver message ${err}`);

src/lib/interfaces.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export interface IMessageFailedEvent {
6565
type: 'message-failed'
6666
recipient: string
6767
message: string
68-
requestID?: string
68+
requestId?: string
6969
}
7070

7171
export interface IBlobReceivedEvent {
@@ -106,14 +106,14 @@ export interface ICommitEvent {
106106
}
107107

108108
export type MessageTask = {
109-
requestID?: string
109+
requestId?: string
110110
message: string
111111
recipient: string
112112
recipientURL: string
113113
}
114114

115115
export type BlobTask = {
116-
requestID?: string
116+
requestId?: string
117117
blobPath: string
118118
recipient: string
119119
recipientURL: string

src/routers/api.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ router.post('/messages', async (req, res, next) => {
138138
if (recipientURL === undefined) {
139139
throw new RequestError(`Unknown recipient`, 400);
140140
}
141-
let requestID = uuidV4();
142-
if(typeof req.body.requestID === 'string') {
143-
requestID = req.body.requestID;
141+
let requestId = uuidV4();
142+
if(typeof req.body.requestId === 'string') {
143+
requestId = req.body.requestId;
144144
}
145-
messagesHandler.sendMessage(req.body.message, req.body.recipient, recipientURL, requestID);
146-
res.send({ requestID });
145+
messagesHandler.sendMessage(req.body.message, req.body.recipient, recipientURL, requestId);
146+
res.send({ requestId });
147147
} catch (err) {
148148
next(err);
149149
}
@@ -211,12 +211,12 @@ router.post('/transfers', async (req, res, next) => {
211211
if (recipientURL === undefined) {
212212
throw new RequestError(`Unknown recipient`, 400);
213213
}
214-
let requestID = uuidV4();
215-
if(typeof req.body.requestID === 'string') {
216-
requestID = req.body.requestID;
214+
let requestId = uuidV4();
215+
if(typeof req.body.requestId === 'string') {
216+
requestId = req.body.requestId;
217217
}
218-
blobsHandler.sendBlob(req.body.path, req.body.recipient, recipientURL, requestID);
219-
res.send({ requestID });
218+
blobsHandler.sendBlob(req.body.path, req.body.recipient, recipientURL, requestId);
219+
res.send({ requestId });
220220
} catch (err) {
221221
next(err);
222222
}

src/swagger.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@
356356
type: string
357357
recipient:
358358
type: string
359-
requestID:
359+
requestId:
360360
type: string
361361
BlobHash:
362362
type: object
@@ -375,14 +375,14 @@
375375
type: string
376376
recipient:
377377
type: string
378-
requestID:
378+
requestId:
379379
type: string
380380
Submitted:
381381
type: object
382382
required:
383-
- requestID
383+
- requestId
384384
properties:
385-
requestID:
385+
requestId:
386386
type: string
387387
Error:
388388
type: object

0 commit comments

Comments
 (0)