
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@abetomo/simply-imitated-sqs
Advanced tools
Simply imitated SQS for testing
Simple SQS class that can be used for local test. You do not even need to use Docker.
% npm install @abetomo/simply-imitated-sqs
sqs
instance'use strict'
// !!!
// If the value of the environment variable LOCAL_TEST is set,
// it will be tested with SimplyImitatedSQS
const AWS = require('aws-sdk')
const sqs = (() => {
// !!! If environment variable is set, use SimplyImitatedSQS
if (process.env.LOCAL_TEST === '1') {
const SimplyImitatedSQS = require('@abetomo/simply-imitated-sqs')
return new SimplyImitatedSQS()
}
return new AWS.SQS({
region: 'us-east-1',
apiVersion: '2012-11-05'
})
})()
// Once you create the sqs instance, you do not need to modify any other code.
const queueUrl = 'https://sqs.us-east-1.amazonaws.com/xxx/test'
Promise.resolve().then(() => {
const params = {
QueueUrl: queueUrl,
MessageBody: 'hoge' + (new Date()).toString()
}
return new Promise(resolve => {
sqs.sendMessage(params, (err, data) => {
if (err) console.error(err)
console.log('+++\n%s\n+++', JSON.stringify(data, null, ' '))
resolve()
})
})
}).then(() => {
const params = { QueueUrl: queueUrl }
return new Promise(resolve => {
sqs.receiveMessage(params, (err, data) => {
if (err) console.error(err)
console.log('===\n%s\n===', JSON.stringify(data, null, ' '))
resolve(data)
})
})
}).then(data => {
const params = {
QueueUrl: queueUrl,
ReceiptHandle: data.Messages[0].ReceiptHandle
}
return new Promise(resolve => {
sqs.deleteMessage(params, (err, data) => {
if (err) console.error(err)
console.log('---\n%s\n---', JSON.stringify(data, null, ' '))
resolve()
})
})
}).then(() => {
if (process.env.LOCAL_TEST === '1') {
// !!! SimplyImitatedSQS creates a file to store the queue, so remove it.
sqs.clear()
}
})
'use strict'
// !!!
// If the value of the environment variable LOCAL_TEST is set,
// it will be tested with SimplyImitatedSQS
const AWS = require('aws-sdk')
const sqs = new AWS.SQS({
region: 'us-east-1',
apiVersion: '2012-11-05'
})
// Existing code remains the same except booting the server
// and reassigning the `queueUrl`.
const server = new (require('@abetomo/simply-imitated-sqs').Server)()
var queueUrl = 'https://sqs.us-east-1.amazonaws.com/xxx/test'
if (process.env.LOCAL_TEST === '1') {
/// !!! Server start and `queueUrl` reassignment
queueUrl = server.run({
port: '1234',
host: 'localhost'
})
}
Promise.resolve().then(() => {
const params = {
QueueUrl: queueUrl,
MessageBody: 'hoge' + (new Date()).toString()
}
return new Promise(resolve => {
sqs.sendMessage(params, (err, data) => {
if (err) console.error(err)
console.log('+++\n%s\n+++', JSON.stringify(data, null, ' '))
resolve()
})
})
}).then(() => {
const params = { QueueUrl: queueUrl }
return new Promise(resolve => {
sqs.receiveMessage(params, (err, data) => {
if (err) console.error(err)
console.log('===\n%s\n===', JSON.stringify(data, null, ' '))
resolve(data)
})
})
}).then(data => {
const params = {
QueueUrl: queueUrl,
ReceiptHandle: data.Messages[0].ReceiptHandle
}
return new Promise(resolve => {
sqs.deleteMessage(params, (err, data) => {
if (err) console.error(err)
console.log('---\n%s\n---', JSON.stringify(data, null, ' '))
resolve()
})
})
}).then(() => {
if (process.env.LOCAL_TEST === '1') {
// !!! Finally shutdown the server
console.log('server shutdown')
server.close()
}
})
# Access AWS.
% node example.js
# Local Completion Test
% LOCAL_TEST=1 node example.js
FAQs
Simply imitated SQS for testing
The npm package @abetomo/simply-imitated-sqs receives a total of 1 weekly downloads. As such, @abetomo/simply-imitated-sqs popularity was classified as not popular.
We found that @abetomo/simply-imitated-sqs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.