diff --git a/backend-func-app/.gitignore b/backend-func-app/.gitignore new file mode 100644 index 0000000..9455707 --- /dev/null +++ b/backend-func-app/.gitignore @@ -0,0 +1,2 @@ +node_modules +local.settings.json diff --git a/backend-func-app/HttpTriggerJS1/function.json b/backend-func-app/HttpTriggerJS1/function.json new file mode 100644 index 0000000..4239627 --- /dev/null +++ b/backend-func-app/HttpTriggerJS1/function.json @@ -0,0 +1,35 @@ +{ + "bindings": [ + { + "type": "httpTrigger", + "direction": "in", + "name": "req", + "route": "hello", + "methods": [ + "get", + "post" + ], + "authLevel": "anonymous" + }, + { + "type": "http", + "direction": "out", + "name": "res" + }, + { + "type": "blob", + "name": "outputBlob", + "path": "output/{filename}", + "connection": "rocketleagueappfunc_STORAGE", + "direction": "out" + }, + { + "type": "table", + "name": "outputTable", + "tableName": "submissions", + "connection": "rocketleagueappfunc_STORAGE", + "direction": "out" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/backend-func-app/HttpTriggerJS1/index.js b/backend-func-app/HttpTriggerJS1/index.js new file mode 100644 index 0000000..d02f69d --- /dev/null +++ b/backend-func-app/HttpTriggerJS1/index.js @@ -0,0 +1,18 @@ +module.exports = function (context, req) { + context.log('JavaScript HTTP trigger function processed a request.', context.bindings.outputBlob); + + context.bindings.outputBlob = req.body; + if (req.query.name || (req.body && req.body.name)) { + context.res = { + // status: 200, /* Defaults to 200 */ + body: "Hello " + (req.query.name || req.body.name) + }; + } + else { + context.res = { + status: 400, + body: "Please pass a name on the query string or in the request body" + }; + } + context.done(); +}; \ No newline at end of file diff --git a/backend-func-app/HttpTriggerPython31/function.json b/backend-func-app/HttpTriggerPython31/function.json new file mode 100644 index 0000000..2111f12 --- /dev/null +++ b/backend-func-app/HttpTriggerPython31/function.json @@ -0,0 +1,20 @@ +{ + "bindings": [ + { + "authLevel": "anonymous", + "type": "httpTrigger", + "direction": "in", + "name": "req", + "methods": [ + "post", + "get" + ] + }, + { + "type": "http", + "direction": "out", + "name": "res" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/backend-func-app/HttpTriggerPython31/run.py b/backend-func-app/HttpTriggerPython31/run.py new file mode 100644 index 0000000..51ca1f8 --- /dev/null +++ b/backend-func-app/HttpTriggerPython31/run.py @@ -0,0 +1,16 @@ +import os +import json +from azure.storage.blob import BlockBlobService + +response = open(os.environ['res'], 'w') + +try: + #postreqdata = json.loads(open(os.environ['req']).read()) + #os.environ['req'] + name = "test" #os.environ['req_query_name'] + response.write("hello world from "+name) +except ValueError as err: + print("Error " + err.message) + +response.close() + diff --git a/backend-func-app/UploadSubmission/function.json b/backend-func-app/UploadSubmission/function.json new file mode 100644 index 0000000..4a32285 --- /dev/null +++ b/backend-func-app/UploadSubmission/function.json @@ -0,0 +1,35 @@ +{ + "bindings": [ + { + "authLevel": "anonymous", + "type": "httpTrigger", + "direction": "in", + "name": "req", + "route": "upload", + "methods": [ + "post", + "get" + ] + }, + { + "type": "http", + "direction": "out", + "name": "res" + }, + { + "type": "table", + "name": "outputTable", + "tableName": "submissions", + "connection": "rocketleagueappfunc_STORAGE", + "direction": "out" + }, + { + "type": "blob", + "name": "submissionBlob", + "path": "uploaded-submissions/{filename}", + "connection": "rocketleagueappfunc_STORAGE", + "direction": "out" + } + ], + "disabled": false +} \ No newline at end of file diff --git a/backend-func-app/UploadSubmission/index.js b/backend-func-app/UploadSubmission/index.js new file mode 100644 index 0000000..0bfb777 --- /dev/null +++ b/backend-func-app/UploadSubmission/index.js @@ -0,0 +1,55 @@ +const azure = require('azure-storage'); +const multer = require('multer'); + + +module.exports = function (context, req) { + context.log('JavaScript HTTP trigger function processed a request.'); + let storageConnection = GetEnvironmentVariable("rocketleagueappfunc_STORAGE"); + context.log(storageConnection); + var blobService = azure.createBlobService(storageConnection); + + blobService.listBlobsSegmented('uploaded-submissions', null, function(error, result, response){ + context.log("blob list"); + if(!error){ + for(entryId in result.entries){ + context.log("entry ", result.entries[entryId].name); + } + // result.entries contains the entries + // If not all blobs were returned, result.continuationToken has the continuation token. + } + }); + + // Iterates through trigger and input binding data + context.bindings.submissionBlob = req.body; + context.bindings.outputTable = []; + /*context.bindings.outputTable.push({ + PartitionKey: "Test", + RowKey: "1234", + Name: "Name " + req.query.name, + Email: "test email 3" + }); + */ + if (req.query.name || (req.body && req.body.name)) { + context.res = { + // status: 200, /* Defaults to 200 */ + body: "Hello " + (req.query.name || req.body.name) + }; + } + else { + context.res = { + status: 400, + body: "Please pass a name on the query string or in the request body" + }; + } + outputBindings = {filename: "test.txt"}; + context.log('output ',outputBindings); + context.log('body', req.body); + context.bindings.submissionBlob = req.body; + + context.done(null, outputBindings ); +}; + +function GetEnvironmentVariable(name) +{ + return process.env[name]; +} \ No newline at end of file diff --git a/backend-func-app/host.json b/backend-func-app/host.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/backend-func-app/host.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/backend-func-app/package.json b/backend-func-app/package.json new file mode 100644 index 0000000..4d3dba7 --- /dev/null +++ b/backend-func-app/package.json @@ -0,0 +1,16 @@ +{ + "name": "rocket_league_func_api", + "version": "1.0.0", + "description": "Rocket league funcitional app", + "productName": " Rocket League", + "author": "yuri.ivanov@capgemini.com", + "private": true, + "scripts": {}, + "dependencies": { + "azure-storage": "^2.10.1" + }, + "engines": { + "node": ">= 8.9.0", + "npm": ">= 5.6.0" + } +} diff --git a/backend-func-app/proxies.json b/backend-func-app/proxies.json new file mode 100644 index 0000000..961655a --- /dev/null +++ b/backend-func-app/proxies.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json.schemastore.org/proxies", + "proxies": { + "home": { + "matchCondition": { + "route": "/", + "methods": [ + "GET" + ] + }, + "backendUri": "https://rocketleagueappfunc.z16.web.core.windows.net/index.html" + }, + "Static Assets": { + "matchCondition": { + "route": "/{*restOfPath}", + "methods": [ + "GET", + "HEAD", + "OPTIONS" + ] + }, + "backendUri": "https://rocketleagueappfunc.z16.web.core.windows.net/{restOfPath}" + }, + "api": { + "matchCondition": { + "route": "/api/{*url}" + }, + "backendUri": "https://%WEBSITE_HOSTNAME%/api/{url}" + } + } +} \ No newline at end of file