This file contains hidden or 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
| const response = { | |
| statusCode: 200, | |
| body: JSON.stringify({ | |
| text: `Hi, ${requestingUser}.\nYour database has been reset!` | |
| }) | |
| }; | |
| callback(null, response); |
This file contains hidden or 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
| let fs = require('fs'); | |
| ... | |
| const resetScript = fs.readFileSync("resetdata.sql"); | |
| const query = `USE ${requestingUser}; ${resetScript}`; | |
| ... | |
| connection.query(query, function (error, results, fields) { | |
| connection.end(); |
This file contains hidden or 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
| let mysql = require('mysql'); | |
| ... | |
| const connection = mysql.createConnection({ | |
| host: "somedatabasehost.com", | |
| user: "someuser", | |
| password: "somepassword", | |
| multipleStatements: true | |
| }); | |
| ... | |
| connection.connect(); |
This file contains hidden or 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
| let querystring = require('querystring'); | |
| ... | |
| const requestingUser = querystring.parse(event.body).user_name; |
This file contains hidden or 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
| service: dbreset | |
| provider: | |
| name: aws | |
| runtime: nodejs6.10 | |
| region: eu-central-1 | |
| functions: | |
| reset: | |
| handler: handler.reset |
This file contains hidden or 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
| 'use strict'; | |
| let fs = require('fs'); | |
| let mysql = require('mysql'); | |
| let querystring = require('querystring'); | |
| module.exports.reset = (event, context, callback) => { | |
| // Extract the Slack username | |
| const requestingUser = querystring.parse(event.body).user_name; |
This file contains hidden or 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
| service: aws-nodejs # NOTE: update this with your service name | |
| provider: | |
| name: aws | |
| runtime: nodejs6.10 | |
| functions: | |
| hello: | |
| handler: handler.hello |
This file contains hidden or 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
| 'use strict'; | |
| module.exports.hello = (event, context, callback) => { | |
| const response = { | |
| statusCode: 200, | |
| body: JSON.stringify({ | |
| message: 'Go Serverless v1.0! Your function executed successfully!', | |
| input: event, | |
| }), | |
| }; |
NewerOlder