{"size": 1481, "ext": "js", "max_stars_repo_path": "local-test/setup_dynamo.js", "max_stars_repo_name": "uwo-openhouse/openhosue-backend", "max_stars_repo_stars_event_min_datetime": "2020-03-26T04:35:51.000Z", "max_stars_repo_stars_event_max_datetime": "2020-03-26T04:51:48.000Z", "max_issues_repo_path": "local-test/setup_dynamo.js", "max_issues_repo_name": "uwo-openhouse/openhosue-backend", "max_issues_repo_issues_event_min_datetime": "2020-01-24T07:11:49.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-11T02:04:43.000Z", "max_forks_repo_path": "local-test/setup_dynamo.js", "max_forks_repo_name": "uwo-openhouse/openhosue-backend", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 23.140625, "max_line_length": 78, "alphanum_fraction": 0.4983119514}
/**
 * This script set ups a local dynamoDB tables to run the application locally.
 */

const tables = [{
    name: 'OpenHouse-Areas',
    key: 'uuid'
}, {
    name: 'OpenHouse-Buildings',
    key: 'uuid'
}, {
    name: 'OpenHouse-Eateries',
    key: 'uuid'
}, {
    name: 'OpenHouse-EventAttendees',
    key: 'uuid'
}, {
    name: 'OpenHouse-Events',
    key: 'uuid'
}, {
    name: 'OpenHouse-OpenHouses',
    key: 'uuid'
}, {
    name: 'OpenHouse-OpenHouseAttendees',
    key: 'uuid'
}];

const aws = require('aws-sdk');
aws.config.update({ region: 'us-east-1' });

(async function() {
    try {
        const dynamoDB = new aws.DynamoDB({
            endpoint: 'http://localhost:8000'
        });

        for (const table of tables) {
            const newTable = {
                TableName: table.name,
                AttributeDefinitions: [{
                    AttributeName: table.key,
                    AttributeType: 'S'
                }],
                KeySchema: [{
                    AttributeName: table.key,
                    KeyType: 'HASH'
                }],
                BillingMode: 'PAY_PER_REQUEST',
            };

            console.log(`Creating table with configuration:`);
            console.log(newTable);
            process.stdout.write("...");

            await dynamoDB.createTable(newTable).promise();

            console.log(' Done');
        }
    } catch (err) {
        console.error(err);
        process.exit(1);
    }
})();
