Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
A thin wrapper around AWS's DynamoDB-Local to make using it in unit tests a bit simpler.
A thin wrapper around AWS's DynamoDBLocal to make using it in unit tests a bit simpler.
npm install --save ddb-local
Set an env var for your DynamoDB endpoint in your package.json test script
"scripts": {
"test": "NODE_ENV=test AWS_DDB_ENDPOINT=http://localhost:3547 mocha --timeout 30000"
},
Start up DdbLocal before running your application tests, and shut it down after.
var DdbLocal = require('ddb-local');
describe('ddb', function () {
var ddblocal = new DdbLocal();
before(function (done) {
ddblocal.start(done);
}
describe('application tests...');
after(function (done) {
ddblocal.stop(done);
});
});
Then wihin your application code, any time you create a new DynamoDB client, set the endpoint if the env var is set.
var dynamoParams = {
apiVersion: '2012-08-10',
endpoint: process.env.AWS_DDB_ENDPOINT
};
var dynamo = new AWS.DynamoDB(dynamoParams);
Now when you run $ npm test
your application will be using DynamoDBLocal
instead of the real DynamoDB. Keep in mind that if your application code
assumes your DynamoDB tables already exist, you'll have to create them
in your test setup.
ddb-local supports a few configuration options via both env var and constructor
params new DdbLocal(options)
options.jarDir
or
by setting DEFAULT_DOWNLOAD_PATH
env varoptions.port
or DDB_PORT
AWS_DDB_ENDPOINT
options.inMemory=false
or DDB_LOCAL_IN_MEMORY=false
to use files.var AWS = require('aws-sdk');
var DdbLocal = require('ddb-local');
var assert = require('assert');
var localdb = new DdbLocal();
localdb.start(function (err) {
assert.ifError(err);
// Now use DynamoDB normally, just set the endpoint to localdb.endpoint
var AWS = require('aws-sdk');
var dynamoParams = {
apiVersion: '2012-08-10',
endpoint: localdb.endpoint
};
var client = new AWS.DynamoDB(dynamoParams);
var tableParams = {
TableName: 'test',
AttributeDefinitions: [
{
AttributeName: 'id',
AttributeType: 'S'
}
],
KeySchema: [
{
AttributeName: 'id',
KeyType: 'HASH'
}
],
ProvisionedThroughput: {
ReadCapacityUnits: 5,
WriteCapacityUnits: 5
}
};
client.createTable(tableParams, function (err, result) {
assert.ifError(err);
assert.equal(result.TableDescription.TableName, tableParams.TableName);
done();
});
// Stop LocalDB when you're done
localdb.stop();
});
FAQs
A thin wrapper around AWS's DynamoDB-Local to make using it in unit tests a bit simpler.
The npm package ddb-local receives a total of 3 weekly downloads. As such, ddb-local popularity was classified as not popular.
We found that ddb-local 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.