From deaa030a6dea0ac22dca8bcfa8c1e6df2bb3d2f8 Mon Sep 17 00:00:00 2001 From: davidwells Date: Wed, 5 Apr 2017 12:38:32 -0700 Subject: [PATCH] add hello-world template --- .../create/templates/hello-world/gitignore | 6 +++++ .../create/templates/hello-world/handler.js | 16 +++++++++++++ .../templates/hello-world/serverless.yml | 24 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 lib/plugins/create/templates/hello-world/gitignore create mode 100644 lib/plugins/create/templates/hello-world/handler.js create mode 100644 lib/plugins/create/templates/hello-world/serverless.yml diff --git a/lib/plugins/create/templates/hello-world/gitignore b/lib/plugins/create/templates/hello-world/gitignore new file mode 100644 index 000000000..2b48c8bd5 --- /dev/null +++ b/lib/plugins/create/templates/hello-world/gitignore @@ -0,0 +1,6 @@ +# package directories +node_modules +jspm_packages + +# Serverless directories +.serverless \ No newline at end of file diff --git a/lib/plugins/create/templates/hello-world/handler.js b/lib/plugins/create/templates/hello-world/handler.js new file mode 100644 index 000000000..a4cd7019d --- /dev/null +++ b/lib/plugins/create/templates/hello-world/handler.js @@ -0,0 +1,16 @@ +'use strict'; + +module.exports.helloWorld = (event, context, callback) => { + const response = { + statusCode: 200, + headers: { + "Access-Control-Allow-Origin" : "*" // Required for CORS support to work + }, + body: JSON.stringify({ + message: 'Go Serverless v1.0! Your function executed successfully!', + input: event, + }), + }; + + callback(null, response); +}; diff --git a/lib/plugins/create/templates/hello-world/serverless.yml b/lib/plugins/create/templates/hello-world/serverless.yml new file mode 100644 index 000000000..7028b27e0 --- /dev/null +++ b/lib/plugins/create/templates/hello-world/serverless.yml @@ -0,0 +1,24 @@ +# Welcome to serverless. Read the docs +# https://serverless.com/framework/docs/ + +# Serverless.yml is the configuration the CLI +# uses to deploy your code to your provider of choice + +# The `service` block is the name of the service +service: serverless-hello-world + +# The `provider` block defines where your service will be deployed +provider: + name: aws + runtime: nodejs6.10 + +# The `functions` block defines what code to deploy +functions: + helloWorld: + handler: handler.helloWorld + # The `events` block defines how to trigger the handler.helloWorld code + events: + - http: + path: hello + method: get + cors: true