diff --git a/lib/plugins/create/create.js b/lib/plugins/create/create.js index ad56f3e2e..5f94711f9 100644 --- a/lib/plugins/create/create.js +++ b/lib/plugins/create/create.js @@ -24,6 +24,8 @@ const validTemplates = [ 'openwhisk-nodejs', 'openwhisk-python', 'openwhisk-swift', + 'spotinst-nodejs', + 'spotinst-python', 'plugin', // this template is used to streamline the onboarding process diff --git a/lib/plugins/create/templates/spotinst-nodejs/gitignore b/lib/plugins/create/templates/spotinst-nodejs/gitignore new file mode 100644 index 000000000..2b48c8bd5 --- /dev/null +++ b/lib/plugins/create/templates/spotinst-nodejs/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/spotinst-nodejs/handler.js b/lib/plugins/create/templates/spotinst-nodejs/handler.js new file mode 100644 index 000000000..71b1474f1 --- /dev/null +++ b/lib/plugins/create/templates/spotinst-nodejs/handler.js @@ -0,0 +1,25 @@ +/* + * + * Implement your function here. + * The function will get the request as a parameter with query/body properties: + * var queryparams = req.query; + * var body = req.body; + * + * The function should return a Promise that resolves with the following structure: + * resolve({ + * statusCode: 200, + * body: '{"hello":"from NodeJS4.8 function"}', + * headers: {"Content-Type": "application/json"} + * }) + * + */ + +exports.main = function main (req, res) { + // The function should return a Promise. + return new Promise(function(resolve, reject){ + return resolve({ + statusCode: 200, + body: `hello ${req.query.name || "world"}!` + }); + }); +}; diff --git a/lib/plugins/create/templates/spotinst-nodejs/package.json b/lib/plugins/create/templates/spotinst-nodejs/package.json new file mode 100644 index 000000000..fca1987e1 --- /dev/null +++ b/lib/plugins/create/templates/spotinst-nodejs/package.json @@ -0,0 +1,10 @@ +{ + "name": "spotionst-nodejs", + "version": "1.0.0", + "description": "Spotinst Functions NodeJS sample for serverless framework service.", + "main": "handler.js", + "keywords": [ + "serverless", + "spotinst" + ] +} diff --git a/lib/plugins/create/templates/spotinst-nodejs/serverless.yml b/lib/plugins/create/templates/spotinst-nodejs/serverless.yml new file mode 100644 index 000000000..af88df7a1 --- /dev/null +++ b/lib/plugins/create/templates/spotinst-nodejs/serverless.yml @@ -0,0 +1,39 @@ +# Welcome to Serverless! +# +# This file is the main config file for your service. +# It's very minimal at this point and uses default values. +# You can always add more config options for more control. +# We've included some commented out config examples here. +# Just uncomment any of them to get that config option. +# +# For full config options, check the docs: +# docs.serverless.com +# +# Happy Coding! + +service: spotinst-nodejs # NOTE: update this with your service name + +provider: + name: spotinst + runtime: nodejs4.8 + #environment: # NOTE: Remember to add the environment ID + #account: # NOTE: Remember to add the account ID + +# you can add packaging information here +#package: +# include: +# - include-me.js +# - include-me-dir/** +# exclude: +# - exclude-me.js +# - exclude-me-dir/** + +functions: + hello: + handler: main + + +# extend the framework using plugins listed here: +# https://github.com/serverless/plugins +plugins: + - serverless-spotinst-functions \ No newline at end of file diff --git a/lib/plugins/create/templates/spotinst-python/gitignore b/lib/plugins/create/templates/spotinst-python/gitignore new file mode 100644 index 000000000..2b48c8bd5 --- /dev/null +++ b/lib/plugins/create/templates/spotinst-python/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/spotinst-python/handler.py b/lib/plugins/create/templates/spotinst-python/handler.py new file mode 100644 index 000000000..ebf78217b --- /dev/null +++ b/lib/plugins/create/templates/spotinst-python/handler.py @@ -0,0 +1,14 @@ + + # Implement your function here. + # The function will get the request as parameter. + # The function should return an object + +def main(args): + queryparams = args.get("query", {}) + body = args.get("body", {}) + + return { + 'statusCode': 200, + 'body': '{"hello":"from Python2.7 function"}', + 'headers': {"Content-Type": "application/json"} + } \ No newline at end of file diff --git a/lib/plugins/create/templates/spotinst-python/serverless.yml b/lib/plugins/create/templates/spotinst-python/serverless.yml new file mode 100644 index 000000000..af88df7a1 --- /dev/null +++ b/lib/plugins/create/templates/spotinst-python/serverless.yml @@ -0,0 +1,39 @@ +# Welcome to Serverless! +# +# This file is the main config file for your service. +# It's very minimal at this point and uses default values. +# You can always add more config options for more control. +# We've included some commented out config examples here. +# Just uncomment any of them to get that config option. +# +# For full config options, check the docs: +# docs.serverless.com +# +# Happy Coding! + +service: spotinst-nodejs # NOTE: update this with your service name + +provider: + name: spotinst + runtime: nodejs4.8 + #environment: # NOTE: Remember to add the environment ID + #account: # NOTE: Remember to add the account ID + +# you can add packaging information here +#package: +# include: +# - include-me.js +# - include-me-dir/** +# exclude: +# - exclude-me.js +# - exclude-me-dir/** + +functions: + hello: + handler: main + + +# extend the framework using plugins listed here: +# https://github.com/serverless/plugins +plugins: + - serverless-spotinst-functions \ No newline at end of file