Created
September 11, 2015 12:27
-
-
Save juyal-ahmed/60cf11569dfc4080019f to your computer and use it in GitHub Desktop.
Using DynamoDB with Node.js, Express.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var aws_router = require('./routes/aws'); | |
app.use('/aws', aws_router); | |
//npm install aws-sdk | |
//visit http://localhost:3000/aws/table-list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var router = express.Router(); | |
var AWS = require('aws-sdk'); | |
AWS.config.loadFromPath('./config.json'); | |
AWS.config.apiVersions = { | |
//dynamodb: '2011-12-05', | |
//ec2: '2013-02-01', | |
dynamodb: 'latest' | |
} | |
var db = new AWS.DynamoDB(); | |
router.get('/table-list', function(req, res, next) { | |
db.listTables(function(err, data) { | |
console.log(data.TableNames); | |
}); | |
res.send('AWS - See the console plz.'); | |
}); | |
module.exports = router; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "accessKeyId": "xxx", "secretAccessKey": "xxx", "region": "us-east-1" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great help :)