https://github.com/fgiova/mini-sqs-client
Mini sqs client using unidici as http agent
https://github.com/fgiova/mini-sqs-client
aws sqs sqs-client sqs-consumer sqs-producer undici
Last synced: about 2 months ago
JSON representation
Mini sqs client using unidici as http agent
- Host: GitHub
- URL: https://github.com/fgiova/mini-sqs-client
- Owner: fgiova
- License: mit
- Created: 2023-10-13T15:00:12.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-11T21:43:29.000Z (2 months ago)
- Last Synced: 2025-03-11T21:45:17.015Z (2 months ago)
- Topics: aws, sqs, sqs-client, sqs-consumer, sqs-producer, undici
- Language: TypeScript
- Homepage:
- Size: 159 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# mini sqs client using undici
[](https://www.npmjs.com/package/@fgiova/mini-sqs-client)

[](http://www.typescriptlang.org/)
[](https://codeclimate.com/github/fgiova/mini-sqs-client/maintainability)
[](https://codeclimate.com/github/fgiova/mini-sqs-client/test_coverage)## Description
This module allows minimal set of SQS service functions using the aws-json protocol with "undici" as http agent.
The @fgiova/aws-signature module is used for signing requests to optimize performance.Are supported:
- sending messages
- receiving messages
- deleting messages
- changing message visibility## Installation
```bash
npm install @fgiova/mini-sqs-client
```
## Usage```typescript
import {MiniSQSClient} from '@fgiova/mini-sqs-client'
import console = require("console");const client = new MiniSQSClient("eu-central-1");
await client.sendMessage("arn:aws:sqs:eu-central-1:000000000000:test", {
MessageBody: "Hello world",
MessageAttributes: {
"my-attribute": {
DataType: "String",
StringValue: "my-value"
}
}
});const messages = await client.receiveMessage("arn:aws:sqs:eu-central-1:000000000000:test", {
WaitTimeSeconds: 20,
MaxNumberOfMessages: 1,
MessageAttributeNames: ["my-attribute"]
});const message = messages[0];
await client.changeMessageVisibility("arn:aws:sqs:eu-central-1:000000000000:test", {
ReceiptHandle: message.ReceiptHandle,
VisibilityTimeout: 10
});console.log(message.Body);
await client.deleteMessage("arn:aws:sqs:eu-central-1:000000000000:test", message.ReceiptHandle);
```## API
```typescript
MiniSQSClient(region: string, endpoint?: string, undiciOptions?: Pool.Options, signer?: Signer | SignerOptions)
MiniSQSClient.sendMessage(queueARN: string, message: SendMessage): Promise
MiniSQSClient.sendMessageBatch(queueARN: string, messages: SendMessage[]): Promise
MiniSQSClient.receiveMessage(queueARN: string, options: ReceiveMessage): Promise
MiniSQSClient.deleteMessage(queueARN: string, receiptHandle: string): Promise
MiniSQSClient.deleteMessageBatch(queueARN: string, receiptHandles: string[]): Promise
MiniSQSClient.changeMessageVisibility(queueARN: string, receiptHandle: string, visibilityTimeout: number): Promise
MiniSQSClient.changeMessageVisibilityBatch(queueARN: string, receiptHandles: string[], visibilityTimeout: number): Promise
MiniSQSClient.destroy(signer: boolean): Promise // signer destroyer default true
```All types are defined in [schemas.ts](./src/schemas.ts) and are derived from the [AWS SQS API](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_Operations.html)
The main difference is that batch operations are not limited to 10 items, but accept any number of items and provide for running the batches needed to exhaust the total number of items.## License
Licensed under [MIT](./LICENSE).