Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

June 16 deploy #28

Merged
merged 4 commits into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ KAFKA_CLIENT_CERT_KEY=$(eval "echo \$${ENV}_KAFKA_CLIENT_CERT_KEY")
KAFKA_URL=$(eval "echo \$${ENV}_KAFKA_URL")
ZOO_KEEPER=$(eval "echo \$${ENV}_ZOO_KEEPER")
TOPIC=$(eval "echo \$${ENV}_TOPIC")
MONGODB_URI=$(eval "echo \$${ENV}_MONGODB_URI")

LOG_LEVEL=$(eval "echo \$${ENV}_LOG_LEVEL")
NODE_ENV=$(eval "echo \$${ENV}_NODE_ENV")
Expand Down
6 changes: 3 additions & 3 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ module.exports = {
}
},
DYNAMODB: {
// AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID || '',
// AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY || '',
AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID || '',
AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY || '',
AWS_REGION: process.env.AWS_REGION || '',
IS_LOCAL: process.env.IS_LOCAL === 'true' || 'false'
IS_LOCAL: process.env.IS_LOCAL || 'false'
}
};
8 changes: 1 addition & 7 deletions models/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ const schema = new Schema({
title: {type: String, required: true},
tcDirectId: {
type: Number,
required: true,
index: {
global: true,
rangeKey: 'id',
project: true,
name: 'TcDirectIdIndex'
}
required: true
},
repoUrl: {type: String, required: true},
repoId: {type: String, required: false},
Expand Down
23 changes: 4 additions & 19 deletions models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,16 @@
const config = require('config');
const dynamoose = require('dynamoose');


const awsConfigs = config.DYNAMODB.IS_LOCAL_DB ? {
dynamoose.AWS.config.update({
accessKeyId: config.DYNAMODB.AWS_ACCESS_KEY_ID,
secretAccessKey: config.DYNAMODB.AWS_SECRET_ACCESS_KEY,
region: config.DYNAMODB.AWS_REGION
} : {
region: config.DYNAMODB.AWS_REGION
};

dynamoose.AWS.config.update(awsConfigs);
});

if (config.DYNAMODB.IS_LOCAL_DB) {
dynamoose.local(config.DYNAMODB.DYNAMODB_URL);
if (config.DYNAMODB.IS_LOCAL === 'true') {
dynamoose.local();
}

// dynamoose.AWS.config.update({
// // accessKeyId: config.DYNAMODB.AWS_ACCESS_KEY_ID,
// // secretAccessKey: config.DYNAMODB.AWS_SECRET_ACCESS_KEY,
// region: config.DYNAMODB.AWS_REGION
// });

// if (config.DYNAMODB.IS_LOCAL === 'true') {
// dynamoose.local();
// }

dynamoose.setDefaults({
create: false,
update: false
Expand Down
23 changes: 2 additions & 21 deletions utils/db-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,6 @@ async function scan(model, scanParams) {
});
}

/**
* Get single data by scan parameters
* @param {Object} model The dynamoose model to scan
* @param {Object} scanParams The scan parameters object
* @returns {Promise<void>}
*/
async function scanOne(model, scanParams) {
return await new Promise((resolve, reject) => {
model.scan(scanParams).consistent().all().exec((err, result) => {
if (err) {
reject(err);
}

return resolve(result[0]);
});
});
}

module.exports = {
scan,
scanOne
};
scan
};