Skip to content

Commit

Permalink
Merge pull request #5 from LOKE/feature/selective-import
Browse files Browse the repository at this point in the history
Allow importing from subpaths
  • Loading branch information
denwilliams authored Sep 3, 2024
2 parents 8fb201e + 9c4e2ee commit 199ba24
Show file tree
Hide file tree
Showing 11 changed files with 1,337 additions and 1,212 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [18.x, 20.x, 22.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -28,7 +28,6 @@ jobs:
env:
RABBIT_URL: amqp://127.0.0.1:${{ job.services.rabbitmq.ports['5672'] }}


publish:
needs: test
runs-on: ubuntu-latest
Expand All @@ -41,4 +40,4 @@ jobs:
- run: npm install
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
token: ${{ secrets.NPM_TOKEN }}
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ A lib for rabbit and sqs queues

# Rabbit

Handling a work queue
Requires `amqplib` to be installed separately. If you only need RabbitMQ support you can avoid also needing to install `@aws-sdk` packages by importing from `"@loke/queue-kit/rabbit"`.

Handling a work queue:

```ts
import { RabbitHelper } from "@loke/queue-kit";
import amqp from "amqplib";
import { RabbitHelper } from "@loke/queue-kit"; // or "@loke/queue-kit/rabbit"
import amqp from "amqplib"; // must be installed separately

async function main() {
const amqpConnection = await amqp.connect("amqp://localhost");
Expand Down Expand Up @@ -69,11 +71,11 @@ const doneP = await Promise.all([
]);
```

Publishing events
Publishing events:

```ts
import { RabbitHelper } from "@loke/queue-kit";
import amqp from "amqplib";
import { RabbitHelper } from "@loke/queue-kit"; // or "@loke/queue-kit/rabbit"
import amqp from "amqplib"; // must be installed separately

async function main() {
const amqpConnection = await amqp.connect("amqp://localhost");
Expand All @@ -91,15 +93,17 @@ async function main() {

## SQS

Handling a queue
Requires `@aws-sdk/client-sqs` to be installed separately. If you only need SQS support you can avoid also needing to install `amqplib` by importing from `"@loke/queue-kit/sqs"`.

Handling a queue:

```ts
import { SQSHelper } from "@loke/queue-kit";
import SQS from "aws-sdk/clients/sqs";
import { SQSHelper } from "@loke/queue-kit"; // or "@loke/queue-kit/sqs"
import { SQSClient } from "@aws-sdk/client-sqs"; // must be installed separately

async function main() {
const sqsHelper = new SQSHelper({
sqs: new SQS(),
sqs: new SQSClient(),
logger: console,
});

Expand All @@ -121,15 +125,15 @@ async function main() {
}
```

Queueing work
Queueing work:

```ts
import { SQSHelper } from "@loke/queue-kit";
import SQS from "aws-sdk/clients/sqs";
import { SQSHelper } from "@loke/queue-kit"; // or "@loke/queue-kit/sqs"
import { SQSClient } from "@aws-sdk/client-sqs"; // must be installed separately

async function main() {
const sqsHelper = new SQSHelper({
sqs: new SQS(),
sqs: new SQSClient(),
logger: console,
});

Expand Down
3 changes: 0 additions & 3 deletions index.ts

This file was deleted.

Loading

0 comments on commit 199ba24

Please sign in to comment.