diff --git a/functions/random-names/random-names.js b/functions/random-names/random-names.js new file mode 100755 index 0000000..27d6c4c --- /dev/null +++ b/functions/random-names/random-names.js @@ -0,0 +1,17 @@ +// Docs on event and context https://www.netlify.com/docs/functions/#the-handler-method +const handler = async (event) => { + try { + const subject = event.queryStringParameters.name || 'World' + return { + statusCode: 200, + body: JSON.stringify({ message: `Hello ${subject}` }), + // // more keys you can return: + // headers: { "headerName": "headerValue", ... }, + // isBase64Encoded: true, + } + } catch (error) { + return { statusCode: 500, body: error.toString() } + } +} + +module.exports = { handler } diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 0000000..417d03d --- /dev/null +++ b/netlify.toml @@ -0,0 +1,3 @@ +[build] +publish = "dist" +functions = "functions"