0.0.5 • Published 11 months ago

@xrnher-labs/aws-client v0.0.5

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
11 months ago

USAGE

import { AwsClient, Subscriber, Publisher, ISQSHandler, Uploader, } from "@stageit-labs/aws-client";

// ==== //
/* Initialize aws client first */
const awsClient = new AwsClient({
    region: "us-east-1",
    accessKeyId: "accessKeyId",
    secretAccessKey: "secretAccessKey"
}, logger);

await awsClient.initialize();

// ==== //
/* Subscriber */
class MyHandler implements ISQSHandler {
    public async handle(event: CloudEventV1<any>): Promise<void> {
        // Do something with event
    }
}

const mySubscriber = new Subscriber(awsClient, {
    queueUrl: "<sqs-queue-url>"
});
mySubscriber.registerHandler("on-unit-created", new MyHandler());

// ==== //
/* Publisher */
const myPublisher = new Publisher(awsClient, "<sns-topic>", "source");

const event = myPublisher.createNewEvent("on-unit-updated", { unitId: 123 });
myPublisher.publish(event);

// OR use shorthand version
myPublisher.publishEvent("on-unit-updated", { unitId: 123 });

// ==== //
/* Uploader (S3) */
const uploader = new Uploader(awsClient, "my-bucket");
uploader.put("s3-key", "my-content");
0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

12 months ago

0.0.1

12 months ago