How do you fake sqs in NODEJS
Amazon SQS is a queue service to have a produce and consume message patten in any applications.
Since Amazon SQS is a SASS Service, During development,Fake SQS is required to test messages for Amazon SQS.
Fake SQS Nodejs Example
First create a node project
npm init -y
Create a index.js file and below lines of code
- Import fake-sqs and aws-sdk into the file
const SQSServer = require("fake-sqs");
const AWS = require("aws-sdk");
- Create a Fake SQS server with ports and optional hosts
const server = new SQSServer(opts);
port: can be zero or any custom port given bootstrap() method
You can start the server using
await server.bootstrap();
Next, Create SQS connection with all region, accessKeyId and Secret key details all details
const sqs = new AWS.SQS({
region: "us-west-2",
sslEnabled: false,
accessKeyId: "456",
secretAccessKey: "asdfa",
apiVersion: "2023-01-05",
});