Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ddb.scan(params, function(err, data) {
if (err) {
send(res, 500, err);
} else {
// res.Items is returned as an array
if (data.Items && data.Items.length) {
// Unmarshall, aka reformat, the results to regular JSON format
let unmarshalled = data.Items.map(item =>
AWS.DynamoDB.Converter.unmarshall(item)
);
data.Items = unmarshalled; // We want to keep the other data points from DynamoDB
}
send(res, 200, data);
}
});
};
const verifyMessengerWebhook = ({ verifyToken }) => (req, res) => {
const { query } = url.parse(req.url, true);
if (
query['hub.mode'] === 'subscribe' &&
query['hub.verify_token'] === verifyToken
) {
send(res, 200, query['hub.challenge']);
} else {
console.error('Failed validation. Make sure the validation tokens match.');
send(res, 403);
}
};
module.exports = async function (req, res) {
const body = await json(req)
const { name, filter } = body
let image, result
try {
image = await convert(name, filter)
result = await s3move(name, image)
} catch (e) {
console.log(e.stack)
return send(res, 500, e.message)
}
send(res, 200, { name: name, src: result.Location })
}
ddb.putItem(params, (err, data) => {
if (err) {
console.log('Error', err);
send(res, 500, err);
} else {
console.log('Success', data);
send(res, 200, { ...data, user_id: uniqueId, name: data.name });
}
});
} catch (e) {
const server = micro(async (req, res) => {
try {
const people = await getData(peopleAPIURL)
const locations = await getData(locationsAPIURL)
return send(res, 200, {
readme,
people,
locations
})
} catch (err) {
return send(res, 500, 'Internal Server Error')
}
})
handle({ res }: Context) {
this.headers.forEach(([key, value]) => {
res.setHeader(key, value)
})
send(res, this.statusCode, this.data)
}
}
module.exports = async function (req, res) {
const body = await json(req)
const { name, filter } = body
const type = mime.lookup(name)
let preview
try {
preview = await convert(name, filter)
} catch (e) {
send(res, 500, e.message)
}
const imagePreview = `data:${type};base64,${preview.toString('base64')}`
send(res, 200, { image: imagePreview })
}
.then(function(docs) {
if (docs.length == 0) send(res, statusCode, { error: "No record found" });
else send(res, statusCode, docs);
})
.catch(function(err) {
.then(function(docs) {
if (docs.length == 0) send(res, statusCode, { error: "No record found" });
else send(res, statusCode, docs);
})
.catch(function(err) {
addElevation(geojson, tiles, function(err, geojson) {
if (err) {
return send(res, 500, err)
}
resolve(geojson)
}, noData)
})