aws-v3-sdk 1.0.16 → 1.0.17
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/clients/all.js +2 -0
- package/clients/sns.js +27 -0
- package/clients/sqs.js +69 -0
- package/package.json +1 -1
package/clients/all.js
CHANGED
package/clients/sns.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { SNSClient, PublishCommand } = require("@aws-sdk/client-sns");
|
|
2
|
+
const snsClient = new SNSClient({});
|
|
3
|
+
|
|
4
|
+
class SNS {
|
|
5
|
+
publish (params, callback) {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
let publishCommand = new PublishCommand(params)
|
|
8
|
+
const response = snsClient.send(publishCommand).then(response=>{
|
|
9
|
+
resolve(response)
|
|
10
|
+
}).catch(err=>{
|
|
11
|
+
reject(err)
|
|
12
|
+
})
|
|
13
|
+
}).then(result => {
|
|
14
|
+
if (callback && typeof callback === 'function') {
|
|
15
|
+
callback(null, result)
|
|
16
|
+
}
|
|
17
|
+
return result
|
|
18
|
+
}).catch(error => {
|
|
19
|
+
if (callback && typeof callback === 'function') {
|
|
20
|
+
callback(error, null)
|
|
21
|
+
}
|
|
22
|
+
return Promise.reject(error)
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = SNS
|
package/clients/sqs.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const { SQSClient, ReceiveMessageCommand, DeleteMessageCommand, SendMessageCommand } = require("@aws-sdk/client-sqs");
|
|
2
|
+
const snsClient = new SQSClient();
|
|
3
|
+
|
|
4
|
+
class SQS {
|
|
5
|
+
sendMessage (params, callback) {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const command = new SendMessageCommand(params)
|
|
8
|
+
const response = snsClient.send(command).then(response=>{
|
|
9
|
+
resolve(response)
|
|
10
|
+
}).catch(err=>{
|
|
11
|
+
reject(err)
|
|
12
|
+
})
|
|
13
|
+
}).then(result => {
|
|
14
|
+
if (callback && typeof callback === 'function') {
|
|
15
|
+
callback(null, result)
|
|
16
|
+
}
|
|
17
|
+
return result
|
|
18
|
+
}).catch(error => {
|
|
19
|
+
if (callback && typeof callback === 'function') {
|
|
20
|
+
callback(error, null)
|
|
21
|
+
}
|
|
22
|
+
return Promise.reject(error)
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
receiveMessage (params, callback) {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
const command = new ReceiveMessageCommand(params)
|
|
29
|
+
const response = snsClient.send(command).then(response=>{
|
|
30
|
+
resolve(response)
|
|
31
|
+
}).catch(err=>{
|
|
32
|
+
reject(err)
|
|
33
|
+
})
|
|
34
|
+
}).then(result => {
|
|
35
|
+
if (callback && typeof callback === 'function') {
|
|
36
|
+
callback(null, result)
|
|
37
|
+
}
|
|
38
|
+
return result
|
|
39
|
+
}).catch(error => {
|
|
40
|
+
if (callback && typeof callback === 'function') {
|
|
41
|
+
callback(error, null)
|
|
42
|
+
}
|
|
43
|
+
return Promise.reject(error)
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
deleteMessage (params, callback) {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
const command = new DeleteMessageCommand(params)
|
|
50
|
+
const response = snsClient.send(command).then(response=>{
|
|
51
|
+
resolve(response)
|
|
52
|
+
}).catch(err=>{
|
|
53
|
+
reject(err)
|
|
54
|
+
})
|
|
55
|
+
}).then(result => {
|
|
56
|
+
if (callback && typeof callback === 'function') {
|
|
57
|
+
callback(null, result)
|
|
58
|
+
}
|
|
59
|
+
return result
|
|
60
|
+
}).catch(error => {
|
|
61
|
+
if (callback && typeof callback === 'function') {
|
|
62
|
+
callback(error, null)
|
|
63
|
+
}
|
|
64
|
+
return Promise.reject(error)
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
module.exports = SQS
|