I am writing an API which gets results from a DynamoDB table and puts the JSON back into the browser.
The code below works and returns the desired results. However, after reading about async and callbacks, it's becoming important for me to know if I should be writing this in another way. Does the following scale well with hundreds of concurrent API callers?
This code does not seem to be using callbacks. Is it asynchronous?
var restify = require('restify'); var AWS = require('aws-sdk'); AWS.config.update({region: 'us-east-1'}); var db = new AWS.DynamoDB(); function myFunction(req, res, next) { var params = { TableName : 'myTable', KeyConditions : { "number" : { "AttributeValueList" : [ { "S" : req.params.simethingid } ], "ComparisonOperator" : "EQ" } } } db.query(params, function(err, data) { if (err) { console.log(err); } else { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain; charset=UTF-8'); res.send(JSON.stringify(data, undefined, 2)); console.log(JSON.stringify(data, undefined, 2)) res.end(); } }); return next(); } server.get('/searchme/:somethingid', myFunction);