Skip to content

Commit

Permalink
Fix code offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
exoego committed Nov 28, 2023
1 parent 4470d2c commit 0c2acbd
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 201 deletions.
3 changes: 2 additions & 1 deletion actions/describeTimeToLive.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module.exports = function describeTimeToLive (store, data, cb) {

if (table.TimeToLiveDescription !== null && typeof table.TimeToLiveDescription === 'object') {
cb(null, { TimeToLiveDescription: table.TimeToLiveDescription })
} else {
}
else {
cb(null, { TimeToLiveDescription: { TimeToLiveStatus: 'DISABLED' } })
}
})
Expand Down
61 changes: 31 additions & 30 deletions actions/updateTimeToLive.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
var db = require('../db');
var db = require('../db')

module.exports = function updateTimeToLive(store, data, cb) {
var key = data.TableName,
TimeToLiveSpecification = data.TimeToLiveSpecification,
tableDb = store.tableDb,
returnValue;
module.exports = function updateTimeToLive (store, data, cb) {
var key = data.TableName,
TimeToLiveSpecification = data.TimeToLiveSpecification,
tableDb = store.tableDb,
returnValue

store.getTable(key, false, function(err, table) {
if (err) return cb(err)
store.getTable(key, false, function (err, table) {
if (err) return cb(err)

if (TimeToLiveSpecification.Enabled) {
if (table.TimeToLiveDescription && table.TimeToLiveDescription.TimeToLiveStatus === 'ENABLED') {
return cb(db.validationError('TimeToLive is already enabled'))
}
table.TimeToLiveDescription = {
AttributeName: TimeToLiveSpecification.AttributeName,
TimeToLiveStatus: 'ENABLED',
}
returnValue = TimeToLiveSpecification
} else {
if (table.TimeToLiveDescription == null || table.TimeToLiveDescription.TimeToLiveStatus === 'DISABLED') {
return cb(db.validationError('TimeToLive is already disabled'))
}
if (TimeToLiveSpecification.Enabled) {
if (table.TimeToLiveDescription && table.TimeToLiveDescription.TimeToLiveStatus === 'ENABLED') {
return cb(db.validationError('TimeToLive is already enabled'))
}
table.TimeToLiveDescription = {
AttributeName: TimeToLiveSpecification.AttributeName,
TimeToLiveStatus: 'ENABLED',
}
returnValue = TimeToLiveSpecification
}
else {
if (table.TimeToLiveDescription == null || table.TimeToLiveDescription.TimeToLiveStatus === 'DISABLED') {
return cb(db.validationError('TimeToLive is already disabled'))
}

table.TimeToLiveDescription = {
TimeToLiveStatus: 'DISABLED',
}
returnValue = {Enabled: false}
}
table.TimeToLiveDescription = {
TimeToLiveStatus: 'DISABLED',
}
returnValue = { Enabled: false }
}

tableDb.put(key, table, function(err) {
if (err) return cb(err)
tableDb.put(key, table, function (err) {
if (err) return cb(err)

cb(null, {TimeToLiveSpecification: returnValue})
})
cb(null, { TimeToLiveSpecification: returnValue })
})
})
}
Loading

0 comments on commit 0c2acbd

Please sign in to comment.