@beesolve/sqs-handler
v0.1.22
Published
Install the latest version of package:
Downloads
516
Readme
SQS handler
Installation
Install the latest version of package:
npm i @beesolve/sqs-handlerUsage
Create tasks.ts file in your server application, which defines your handlers.
import { createSqsHandlers } from "@beesolve/sqs-handler";
import { SQSClient } from "@aws-sdk/client-sqs";
export const [handler, tasks] = createSqsHandlers({
fifo: false, // you can create either fifo or standard queues
sqsClient: new SQSClient(), // provide SQS client
queueUrls: { main: process.env.BEESOLVE_TASKS_QUEUE_URL! }, // BEESOLVE_TASKS_QUEUE_URL env variable will be automatically injected to your Lambda function
functions: {
// here goes your functions
test: async (payload: any) => {
console.log({ payload });
},
},
});Create SqsHandler instance with CDK.
import { SqsHandler } from "@beesolve/sqs-handler/cdk";
const sqsHandler = new SqsHandler(stack, "SqsHandler", {
entry: resolve(`src/lib/server/tasks.ts`), // path to your `tasks.ts` file
handlerProps: {
memorySize: 1024,
timeout: Duration.seconds(5),
},
alarms,
});
sqsHandler.grantAccess(handler);https://logtape.org/manual/install
