dynamodb-admin
Advanced tools
Comparing version 3.1.0 to 3.1.1
const express = require('express') | ||
const {promisify} = require('es6-promisify') | ||
const path = require('path') | ||
@@ -9,2 +8,3 @@ const fs = require('fs') | ||
const { purgeTable } = require('./actions/purgeTable') | ||
const asyncMiddleware = require('./utils/asyncMiddleware') | ||
const bodyParser = require('body-parser') | ||
@@ -132,7 +132,7 @@ const pickBy = require('lodash/pickBy') | ||
const listTables = promisify(dynamodb.listTables.bind(dynamodb)) | ||
const describeTable = promisify(dynamodb.describeTable.bind(dynamodb)) | ||
const getItem = promisify(docClient.get.bind(docClient)) | ||
const putItem = promisify(docClient.put.bind(docClient)) | ||
const deleteItem = promisify(docClient.delete.bind(docClient)) | ||
const listTables = (...args) => dynamodb.listTables(...args).promise() | ||
const describeTable = (...args) => dynamodb.describeTable(...args).promise() | ||
const getItem = (...args) => docClient.get(...args).promise() | ||
const putItem = (...args) => docClient.put(...args).promise() | ||
const deleteItem = (...args) => docClient.delete(...args).promise() | ||
@@ -142,3 +142,3 @@ app.use(errorhandler()) | ||
app.get('/', (req, res) => { | ||
app.get('/', asyncMiddleware((req, res) => { | ||
const listAllTables = (lastEvaluatedTableName, tableNames) => { | ||
@@ -159,10 +159,7 @@ return listTables({ ExclusiveStartTableName: lastEvaluatedTableName }) | ||
listAllTables(null, []) | ||
return listAllTables(null, []) | ||
.then(data => { | ||
res.render('tables', { data }) | ||
}) | ||
.catch(error => { | ||
res.json({ error }) | ||
}) | ||
}) | ||
})) | ||
@@ -176,3 +173,3 @@ app.get('/create-table', (req, res) => { | ||
bodyParser.urlencoded({ extended: false, limit: '500kb' }), | ||
(req, res, next) => { | ||
asyncMiddleware((req, res) => { | ||
const attributeDefinitions = [ | ||
@@ -204,3 +201,3 @@ { | ||
dynamodb | ||
return dynamodb | ||
.createTable({ | ||
@@ -219,9 +216,8 @@ TableName: req.body.TableName, | ||
}) | ||
.catch(next) | ||
} | ||
}) | ||
) | ||
app.delete('/tables/:TableName', (req, res, next) => { | ||
app.delete('/tables/:TableName', asyncMiddleware((req, res) => { | ||
const TableName = req.params.TableName | ||
dynamodb | ||
return dynamodb | ||
.deleteTable({ TableName }) | ||
@@ -232,14 +228,12 @@ .promise() | ||
}) | ||
.catch(next) | ||
}) | ||
})) | ||
app.delete('/tables/:TableName/all', (req, res, next) => { | ||
purgeTable(req.params.TableName, dynamodb) | ||
app.delete('/tables/:TableName/all', asyncMiddleware((req, res) => { | ||
return purgeTable(req.params.TableName, dynamodb) | ||
.then(() => { | ||
res.status(200).end() | ||
}) | ||
.catch(next) | ||
}) | ||
})) | ||
app.get('/tables/:TableName/get', (req, res) => { | ||
app.get('/tables/:TableName/get', asyncMiddleware((req, res) => { | ||
const TableName = req.params.TableName | ||
@@ -249,40 +243,42 @@ if (req.query.hash) { | ||
return res.redirect( | ||
`/tables/${TableName}/items/${req.query.hash}${encodeURIComponent( | ||
',' | ||
)}${req.query.range}` | ||
`/tables/${encodeURIComponent(TableName)}/items/${ | ||
encodeURIComponent(req.query.hash)},${encodeURIComponent(req.query.range)}` | ||
) | ||
} else { | ||
return res.redirect(`/tables/${TableName}/items/${req.query.hash}`) | ||
return res.redirect(`/tables/${ | ||
encodeURIComponent(TableName)}/items/${encodeURIComponent(req.query.hash)}`) | ||
} | ||
} | ||
describeTable({ TableName }).then(description => { | ||
const hashKey = description.Table.KeySchema.find(schema => { | ||
return schema.KeyType === 'HASH' | ||
return describeTable({ TableName }) | ||
.then(description => { | ||
const hashKey = description.Table.KeySchema.find(schema => { | ||
return schema.KeyType === 'HASH' | ||
}) | ||
if (hashKey) { | ||
hashKey.AttributeType = description.Table.AttributeDefinitions.find( | ||
definition => { | ||
return definition.AttributeName === hashKey.AttributeName | ||
} | ||
).AttributeType | ||
} | ||
const rangeKey = description.Table.KeySchema.find(schema => { | ||
return schema.KeyType === 'RANGE' | ||
}) | ||
if (rangeKey) { | ||
rangeKey.AttributeType = description.Table.AttributeDefinitions.find( | ||
definition => { | ||
return definition.AttributeName === rangeKey.AttributeName | ||
} | ||
).AttributeType | ||
} | ||
res.render( | ||
'get', | ||
Object.assign({}, description, { | ||
hashKey, | ||
rangeKey | ||
}) | ||
) | ||
}) | ||
if (hashKey) { | ||
hashKey.AttributeType = description.Table.AttributeDefinitions.find( | ||
definition => { | ||
return definition.AttributeName === hashKey.AttributeName | ||
} | ||
).AttributeType | ||
} | ||
const rangeKey = description.Table.KeySchema.find(schema => { | ||
return schema.KeyType === 'RANGE' | ||
}) | ||
if (rangeKey) { | ||
rangeKey.AttributeType = description.Table.AttributeDefinitions.find( | ||
definition => { | ||
return definition.AttributeName === rangeKey.AttributeName | ||
} | ||
).AttributeType | ||
} | ||
res.render( | ||
'get', | ||
Object.assign({}, description, { | ||
hashKey, | ||
rangeKey | ||
}) | ||
) | ||
}) | ||
}) | ||
})) | ||
@@ -320,3 +316,3 @@ const getPage = (docClient, keySchema, TableName, scanParams, pageSize, | ||
app.get('/tables/:TableName', (req, res, next) => { | ||
app.get('/tables/:TableName', asyncMiddleware((req, res) => { | ||
const TableName = req.params.TableName | ||
@@ -326,3 +322,3 @@ req.query = pickBy(req.query) | ||
describeTable({ TableName }) | ||
return describeTable({ TableName }) | ||
.then(description => { | ||
@@ -358,6 +354,5 @@ const pageNum = req.query.pageNum ? parseInt(req.query.pageNum) : 1 | ||
}) | ||
.catch(next) | ||
}) | ||
})) | ||
app.get('/tables/:TableName/items', (req, res, next) => { | ||
app.get('/tables/:TableName/items', asyncMiddleware((req, res) => { | ||
const TableName = req.params.TableName | ||
@@ -367,3 +362,3 @@ req.query = pickBy(req.query) | ||
describeTable({ TableName }) | ||
return describeTable({ TableName }) | ||
.then(description => { | ||
@@ -449,8 +444,7 @@ const ExclusiveStartKey = req.query.startKey | ||
}) | ||
.catch(next) | ||
}) | ||
})) | ||
app.get('/tables/:TableName/meta', (req, res) => { | ||
app.get('/tables/:TableName/meta', asyncMiddleware((req, res) => { | ||
const TableName = req.params.TableName | ||
Promise.all([ | ||
return Promise.all([ | ||
describeTable({ TableName }), | ||
@@ -463,10 +457,7 @@ docClient.scan({ TableName }).promise() | ||
}) | ||
.catch(error => { | ||
res.json({ error }) | ||
}) | ||
}) | ||
})) | ||
app.delete('/tables/:TableName/items/:key', (req, res, next) => { | ||
app.delete('/tables/:TableName/items/:key', asyncMiddleware((req, res) => { | ||
const TableName = req.params.TableName | ||
describeTable({ TableName }) | ||
return describeTable({ TableName }) | ||
.then(result => { | ||
@@ -482,8 +473,7 @@ const params = { | ||
}) | ||
.catch(next) | ||
}) | ||
})) | ||
app.get('/tables/:TableName/add-item', (req, res, next) => { | ||
app.get('/tables/:TableName/add-item', asyncMiddleware((req, res) => { | ||
const TableName = req.params.TableName | ||
describeTable({ TableName }) | ||
return describeTable({ TableName }) | ||
.then(result => { | ||
@@ -505,8 +495,7 @@ const table = result.Table | ||
}) | ||
.catch(next) | ||
}) | ||
})) | ||
app.get('/tables/:TableName/items/:key', (req, res, next) => { | ||
app.get('/tables/:TableName/items/:key', asyncMiddleware((req, res) => { | ||
const TableName = req.params.TableName | ||
describeTable({ TableName }) | ||
return describeTable({ TableName }) | ||
.then(result => { | ||
@@ -530,4 +519,3 @@ const params = { | ||
}) | ||
.catch(next) | ||
}) | ||
})) | ||
@@ -537,5 +525,5 @@ app.put( | ||
bodyParser.json({ limit: '500kb'}), | ||
(req, res, next) => { | ||
asyncMiddleware((req, res) => { | ||
const TableName = req.params.TableName | ||
describeTable({ TableName }) | ||
return describeTable({ TableName }) | ||
.then(description => { | ||
@@ -561,5 +549,3 @@ const params = { | ||
}) | ||
.catch(next) | ||
} | ||
) | ||
})) | ||
@@ -569,5 +555,5 @@ app.put( | ||
bodyParser.json({ limit: '500kb'}), | ||
(req, res, next) => { | ||
asyncMiddleware((req, res) => { | ||
const TableName = req.params.TableName | ||
describeTable({ TableName }) | ||
return describeTable({ TableName }) | ||
.then(result => { | ||
@@ -589,5 +575,3 @@ const params = { | ||
}) | ||
.catch(next) | ||
} | ||
) | ||
})) | ||
@@ -594,0 +578,0 @@ app.use((err, req, res, next) => { |
@@ -1,3 +0,1 @@ | ||
const { promisify } = require('es6-promisify') | ||
exports.extractKey = function(item, KeySchema) { | ||
@@ -74,4 +72,4 @@ return KeySchema.reduce((prev, current) => { | ||
const readMethod = { | ||
scan: promisify(docClient.scan.bind(docClient)), | ||
query: promisify(docClient.query.bind(docClient)), | ||
scan: (...args) => docClient.scan(...args).promise(), | ||
query: (...args) => docClient.query(...args).promise(), | ||
}[readOperation] | ||
@@ -78,0 +76,0 @@ |
{ | ||
"name": "dynamodb-admin", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "GUI for DynamoDB. Useful for local development.", | ||
@@ -29,3 +29,3 @@ "main": "lib/backend.js", | ||
"argparse": "^1.0.10", | ||
"aws-sdk": "^2.329.0", | ||
"aws-sdk": "^2.390.0", | ||
"body-parser": "^1.18.3", | ||
@@ -35,3 +35,2 @@ "cli-color": "^1.3.0", | ||
"errorhandler": "^1.4.3", | ||
"es6-promisify": "^6.0.0", | ||
"es7-object-polyfill": "0.0.7", | ||
@@ -43,7 +42,7 @@ "express": "^4.16.3", | ||
"devDependencies": { | ||
"eslint": "^5.6.1", | ||
"eslint-plugin-jest": "^21.24.1", | ||
"eslint": "^5.12.0", | ||
"eslint-plugin-jest": "^22.1.0", | ||
"jest-cli": "^23.6.0", | ||
"nodemon": "^1.18.6" | ||
"nodemon": "^1.18.9" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
796587
10
34
3930
- Removedes6-promisify@^6.0.0
- Removedes6-promisify@6.1.1(transitive)
Updatedaws-sdk@^2.390.0