Created
July 25, 2023 01:29
-
-
Save maskaravivek/ee325c72f4b6a94fbdf09997bb7ef61e to your computer and use it in GitHub Desktop.
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
/*global exports, require*/ | |
var convert = require("./convert"); | |
exports.handler = async function (event, context) { | |
"use strict"; | |
let body; | |
let statusCode = 200; | |
const headers = { | |
"Content-Type": "application/json", | |
"Access-Control-Allow-Origin": "*", | |
}; | |
let requestJSON = JSON.parse(event.body); | |
try { | |
let inputObjectKey = requestJSON["inputObjectKey"]; | |
let outputObjectKey = requestJSON["outputObjectKey"]; | |
const resp = await convert(inputObjectKey, outputObjectKey); | |
body = { | |
outputObjectKey: resp, | |
}; | |
} catch (err) { | |
console.log("error occurred:", err); | |
statusCode = 400; | |
body = err.message; | |
} finally { | |
body = JSON.stringify(body); | |
} | |
return { | |
statusCode, | |
body, | |
headers, | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment