diff --git a/fc.toml b/fc.toml new file mode 100644 index 0000000..e5730af --- /dev/null +++ b/fc.toml @@ -0,0 +1,17 @@ +app = "nodejs-dockerfile-func-sample" +region = "asia-south1" +handler = "index.handler" + +[build] + builtin = "dockerfile" + ignorefile = ".gitignore" + + [build.args] + param1 = "value1" + param2 = "value2" + +[env] + FOO = "BAR" + +[http_service] + internal_port = 3000 diff --git a/index.js b/index.js new file mode 100644 index 0000000..f3713b5 --- /dev/null +++ b/index.js @@ -0,0 +1,20 @@ +// Define the handler function +export const handler = async (event, context) => { + try { + // Prepare the response JSON + const responseJson = { + message: "Hello World", + }; + // Set the response headers + context.setHeader("Content-Type", "application/json"); + // Send the response JSON + context.end(JSON.stringify(responseJson)); + } catch (error) { + // Handle errors + console.error(error); + // Send an error response if needed + context.statusCode = 500; + context.setHeader("Content-Type", "text/plain"); + context.end("Internal Server Error"); + } +}; \ No newline at end of file