dynamodb-schema-wizard
v0.0.2
Published
<p align="center"> <img src="https://f.smebiz.com/icon/64x64.png" alt="SMEBiz logo"> </p>
Downloads
2
Readme
DynamoDB Schema Wizard
Description
Allows you to replicate DynamoDB tables from AWS account to the dynamodb-local.
API Docs
As there're very few files, please read JSDoc.
Example
scripts/exportDynamoDBSchemas.js
require('dotenv').config();
const { exportSchemasToFile } = require('dynamodb-schema-wizard');
const tables = Object.entries(process.env)
.map(([key, value]) => (key.endsWith('_DYNAMODB_TABLE') ? value : null))
.filter(i => i);
exportSchemasToFile(tables, `${__dirname}/../dynamodb-schema.json`);
src/aws-sdk.js
// eslint-disable-next-line import/no-extraneous-dependencies
const AWS = require('aws-sdk');
if (process.env.NODE_ENV !== 'production') {
AWS.config.update({
endpoint: 'http://localhost:8000'
});
}
module.exports = AWS;
setupTestEnvironment.js
/* eslint-disable import/no-extraneous-dependencies */
require('dotenv').config();
const { createTables } = require('dynamodb-schema-wizard');
const AWS = require('./src/aws-sdk');
const dynamodbSchema = require('./dynamodb-schema.json');
const globalSetup = async globalConfig => {
await createTables(new AWS.DynamoDB(), dynamodbSchema);
};
module.exports = globalSetup;
jest.config.js
module.exports = {
globalSetup: './setupTestEnvironment.js'
};
.env
SOME_DYNAMODB_TABLE=sometable
ANOTHER_DYNAMODB_TABLE=someanothertable