Skip to content

Instantly share code, notes, and snippets.

@kobalski
Created March 6, 2019 12:12
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 kobalski/544a3f2d6248935133f90f1f994a4dba to your computer and use it in GitHub Desktop.
Save kobalski/544a3f2d6248935133f90f1f994a4dba to your computer and use it in GitHub Desktop.
Thundra Example with serverless-mysql
// Require and initialize outside of your main handler
const thundra = require('@thundra/core')();
const mysql = require('serverless-mysql')({
config: {
host : '',
database : '',
user : '',
password : '',
}
);
// Main handler function
exports.handler = thundra(async (event, context) => {
// Run your query
let results = await mysql.query('SELECT * FROM user');
// Run clean up function
await mysql.end();
// Return the results
return results;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment