Created
March 6, 2019 12:12
-
-
Save kobalski/544a3f2d6248935133f90f1f994a4dba to your computer and use it in GitHub Desktop.
Thundra Example with serverless-mysql
This file contains 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
// 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