Skip to content

Commit bfeaa21

Browse files
authored
Merge pull request #2 from fgiova/feature/signer-singleton
feat: add signature singleton
2 parents ff22fe0 + 135e76e commit bfeaa21

File tree

6 files changed

+458
-734
lines changed

6 files changed

+458
-734
lines changed

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: npm i --ignore-scripts
3535

3636
- name: Run tests
37-
run: npm test:coverage
37+
run: npm run test:coverage
3838

3939
- name: publish code coverage to code-climate (duh)
4040
if: ${{ github.event_name == 'push' && matrix.node-version == 20 }} # Push coverage only once inside the matrix.

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,33 @@ const signature = signer.request({
3434
signer.destroy();
3535
```
3636

37+
### SignerSingleton
38+
```js
39+
const { SignerSingleton } = require("@fgiova/aws-signature");
40+
41+
const signer = SignerSingleton.getSigner();
42+
const signature = signer.request({
43+
method: "POST",
44+
path: "/",
45+
headers: {
46+
host: "foo.us-bar-1.amazonaws.com",
47+
},
48+
body: "Action=SendMessage&MessageBody=test&Version=2012-11-05",
49+
}, "sqs");
50+
51+
// Get same instance of Signer
52+
const newSigner = SignerSingleton.getSigner();
53+
54+
// To destroy the thread pool
55+
signer.destroy();
56+
```
57+
3758
### API
3859
```js
3960
Signer(options?: SignerOptions)
4061
Signer.request(request: Request, service: string, region?: string, date?: Date): string
4162
Signer.destroy(): Promise<void>
63+
SignerSingleton.getSigner(options?: SignerOptions): Signer
4264
```
4365
#### Environment variables
4466
* `AWS_ACCESS_KEY_ID` - The AWS access key ID to sign the request with.

0 commit comments

Comments
 (0)