Skip to content

Instantly share code, notes, and snippets.

@garystafford
Last active October 1, 2019 02:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garystafford/8d86f81ab8fb2cdd9868407c7cc1140d to your computer and use it in GitHub Desktop.
Save garystafford/8d86f81ab8fb2cdd9868407c7cc1140d to your computer and use it in GitHub Desktop.
exports.getMessage = async (event, context) => {
if (tableName == null) {
tableName = process.env.TABLE_NAME;
}
params = {
TableName: tableName,
Key: {
"date": event.pathParameters.date,
"time": event.queryStringParameters.time
}
};
console.debug(params.Key);
return await new Promise((resolve, reject) => {
docClient.get(params, (error, data) => {
if (error) {
console.error(`getMessage ERROR=${error.stack}`);
resolve({
statusCode: 400,
error: `Could not get messages: ${error.stack}`
});
} else {
console.info(`getMessage data=${JSON.stringify(data)}`);
resolve({
statusCode: 200,
body: JSON.stringify(data)
});
}
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment