diff --git a/amplify/backend/api/AccountSettingsApi/AccountSettingsApi-cloudformation-template.json b/amplify/backend/api/AccountSettingsApi/AccountSettingsApi-cloudformation-template.json new file mode 100644 index 0000000..1a0a10a --- /dev/null +++ b/amplify/backend/api/AccountSettingsApi/AccountSettingsApi-cloudformation-template.json @@ -0,0 +1,709 @@ +{ + "AWSTemplateFormatVersion": "2010-09-09", + "Description": "API Gateway resource stack creation using Amplify CLI", + + "Parameters": { + "authRoleName": { + "Type": "String" + }, + "unauthRoleName": { + "Type": "String" + }, + "env": { + "Type": "String" + }, + + + "functionAccountSettingsLambdaName": { + "Type": "String", + "Default": "functionAccountSettingsLambdaName" + }, + + + "functionAccountSettingsLambdaArn": { + "Type": "String", + "Default": "functionAccountSettingsLambdaArn" + } + + + + + }, + "Conditions": { + "ShouldNotCreateEnvResources": { + "Fn::Equals": [ + { + "Ref": "env" + }, + "NONE" + ] + } + }, + "Resources": { + + "PolicyAPIGWAccountSettingsApiauth": { + "DependsOn": [ + "AccountSettingsApi" + ], + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyName": "PolicyAPIGWAccountSettingsApiauth", + "Roles": [ + {"Ref": "authRoleName"} + ], + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "execute-api:Invoke" + ], + "Resource": [ + + + + { + "Fn::Join": [ + "", + [ + "arn:aws:execute-api:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "AccountSettingsApi" + }, + "/", + { + "Fn::If": [ + "ShouldNotCreateEnvResources", + "Prod", + { + "Ref": "env" + } + ] + }, + "/POST", + "/account/*" + ] + ] + }, + { + "Fn::Join": [ + "", + [ + "arn:aws:execute-api:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "AccountSettingsApi" + }, + "/", + { + "Fn::If": [ + "ShouldNotCreateEnvResources", + "Prod", + { + "Ref": "env" + } + ] + }, + "/POST", + "/account" + ] + ] + } + + , + + + { + "Fn::Join": [ + "", + [ + "arn:aws:execute-api:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "AccountSettingsApi" + }, + "/", + { + "Fn::If": [ + "ShouldNotCreateEnvResources", + "Prod", + { + "Ref": "env" + } + ] + }, + "/GET", + "/account/*" + ] + ] + }, + { + "Fn::Join": [ + "", + [ + "arn:aws:execute-api:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "AccountSettingsApi" + }, + "/", + { + "Fn::If": [ + "ShouldNotCreateEnvResources", + "Prod", + { + "Ref": "env" + } + ] + }, + "/GET", + "/account" + ] + ] + } + + , + + + { + "Fn::Join": [ + "", + [ + "arn:aws:execute-api:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "AccountSettingsApi" + }, + "/", + { + "Fn::If": [ + "ShouldNotCreateEnvResources", + "Prod", + { + "Ref": "env" + } + ] + }, + "/PUT", + "/account/*" + ] + ] + }, + { + "Fn::Join": [ + "", + [ + "arn:aws:execute-api:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "AccountSettingsApi" + }, + "/", + { + "Fn::If": [ + "ShouldNotCreateEnvResources", + "Prod", + { + "Ref": "env" + } + ] + }, + "/PUT", + "/account" + ] + ] + } + + , + + + { + "Fn::Join": [ + "", + [ + "arn:aws:execute-api:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "AccountSettingsApi" + }, + "/", + { + "Fn::If": [ + "ShouldNotCreateEnvResources", + "Prod", + { + "Ref": "env" + } + ] + }, + "/PATCH", + "/account/*" + ] + ] + }, + { + "Fn::Join": [ + "", + [ + "arn:aws:execute-api:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "AccountSettingsApi" + }, + "/", + { + "Fn::If": [ + "ShouldNotCreateEnvResources", + "Prod", + { + "Ref": "env" + } + ] + }, + "/PATCH", + "/account" + ] + ] + } + + + + + + ] + } + ] + } + } + }, + + + + + + "AccountSettingsApi": { + "Type": "AWS::ApiGateway::RestApi", + "Properties": { + "Description": "", + "Name": "AccountSettingsApi", + "Body": { + "swagger": "2.0", + "info": { + "version": "2018-05-24T17:52:00Z", + "title": "AccountSettingsApi" + }, + "host": { + "Fn::Join": [ + "", + [ + "apigateway.", + { + "Ref": "AWS::Region" + }, + ".amazonaws.com" + ] + ] + }, + "basePath": { + "Fn::If": [ + "ShouldNotCreateEnvResources", + "/Prod", + { + "Fn::Join": [ + "", + [ + "/", + { + "Ref": "env" + } + ] + ] + } + ] + }, + "schemes": [ + "https" + ], + "paths": { + + "/account": { + "options": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "200 response", + "headers": { + "Access-Control-Allow-Origin": { + "type": "string" + }, + "Access-Control-Allow-Methods": { + "type": "string" + }, + "Access-Control-Allow-Headers": { + "type": "string" + } + } + } + }, + "x-amazon-apigateway-integration": { + "responses": { + "default": { + "statusCode": "200", + "responseParameters": { + "method.response.header.Access-Control-Allow-Methods": "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'", + "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Amz-User-Agent'", + "method.response.header.Access-Control-Allow-Origin": "'*'" + } + } + }, + "requestTemplates": { + "application/json": "{\"statusCode\": 200}" + }, + "passthroughBehavior": "when_no_match", + "type": "mock" + } + }, + "x-amazon-apigateway-any-method": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "RequestSchema", + "required": false, + "schema": { + "$ref": "#/definitions/RequestSchema" + } + } + ], + "responses": { + "200": { + "description": "200 response", + "schema": { + "$ref": "#/definitions/ResponseSchema" + } + } + }, + + "security": [ + { + "sigv4": [] + } + ], + + "x-amazon-apigateway-integration": { + "responses": { + "default": { + "statusCode": "200" + } + }, + "uri": { + "Fn::Join": [ + "", + [ + "arn:aws:apigateway:", + { + "Ref": "AWS::Region" + }, + ":lambda:path/2015-03-31/functions/", + + { + + "Ref": "functionAccountSettingsLambdaArn" + }, + + "/invocations" + ] + ] + }, + "passthroughBehavior": "when_no_match", + "httpMethod": "POST", + "type": "aws_proxy" + } + } + }, + "/account/{proxy+}": { + "options": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "200 response", + "headers": { + "Access-Control-Allow-Origin": { + "type": "string" + }, + "Access-Control-Allow-Methods": { + "type": "string" + }, + "Access-Control-Allow-Headers": { + "type": "string" + } + } + } + }, + "x-amazon-apigateway-integration": { + "responses": { + "default": { + "statusCode": "200", + "responseParameters": { + "method.response.header.Access-Control-Allow-Methods": "'DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT'", + "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Amz-User-Agent'", + "method.response.header.Access-Control-Allow-Origin": "'*'" + } + } + }, + "requestTemplates": { + "application/json": "{\"statusCode\": 200}" + }, + "passthroughBehavior": "when_no_match", + "type": "mock" + } + }, + "x-amazon-apigateway-any-method": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "body", + "name": "RequestSchema", + "required": false, + "schema": { + "$ref": "#/definitions/RequestSchema" + } + } + ], + "responses": { + "200": { + "description": "200 response", + "schema": { + "$ref": "#/definitions/ResponseSchema" + } + } + }, + + "security": [ + { + "sigv4": [] + } + ], + + "x-amazon-apigateway-integration": { + "responses": { + "default": { + "statusCode": "200" + } + }, + "uri": { + "Fn::Join": [ + "", + [ + "arn:aws:apigateway:", + { + "Ref": "AWS::Region" + }, + ":lambda:path/2015-03-31/functions/", + + { + + "Ref": "functionAccountSettingsLambdaArn" + }, + + "/invocations" + ] + ] + }, + "passthroughBehavior": "when_no_match", + "httpMethod": "POST", + "type": "aws_proxy" + } + } + } + + }, + "securityDefinitions": { + "sigv4": { + "type": "apiKey", + "name": "Authorization", + "in": "header", + "x-amazon-apigateway-authtype": "awsSigv4" + } + }, + "definitions": { + "RequestSchema": { + "type": "object", + "required": [ + "request" + ], + "properties": { + "request": { + "type": "string" + } + }, + "title": "Request Schema" + }, + "ResponseSchema": { + "type": "object", + "required": [ + "response" + ], + "properties": { + "response": { + "type": "string" + } + }, + "title": "Response Schema" + } + } + }, + "FailOnWarnings": true + } + }, + + + + + "functionAccountSettingsLambdaPermissionAccountSettingsApi": { + "Type": "AWS::Lambda::Permission", + "Properties": { + "FunctionName": + { + "Ref": "functionAccountSettingsLambdaName" + }, + + "Action": "lambda:InvokeFunction", + "Principal": "apigateway.amazonaws.com", + "SourceArn": { + "Fn::Join": [ + "", + [ + "arn:aws:execute-api:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":", + { + "Ref": "AccountSettingsApi" + }, + "/*/*/*" + ] + ] + } + } + }, + + + + "DeploymentAPIGWAccountSettingsApi": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "Description": "The Development stage deployment of your API.", + "StageName": { + "Fn::If": [ + "ShouldNotCreateEnvResources", + "Prod", + { + "Ref": "env" + } + ] + }, + "RestApiId": { + "Ref": "AccountSettingsApi" + } + } + } + }, + "Outputs": { + "RootUrl": { + "Description": "Root URL of the API gateway", + "Value": {"Fn::Join": ["", ["https://", {"Ref": "AccountSettingsApi"}, ".execute-api.", {"Ref": "AWS::Region"}, ".amazonaws.com/", {"Fn::If": ["ShouldNotCreateEnvResources","Prod", {"Ref": "env"} ]}]]} + }, + "ApiName": { + "Description": "API Friendly name", + "Value": "AccountSettingsApi" + }, + "ApiId": { + "Description": "API ID (prefix of API URL)", + "Value": {"Ref": "AccountSettingsApi"} + } + } + } diff --git a/amplify/backend/api/AccountSettingsApi/api-params.json b/amplify/backend/api/AccountSettingsApi/api-params.json new file mode 100644 index 0000000..e839df6 --- /dev/null +++ b/amplify/backend/api/AccountSettingsApi/api-params.json @@ -0,0 +1,40 @@ +{ + "paths": [ + { + "name": "/account", + "lambdaFunction": "AccountSettingsLambda", + "privacy": { + "private": true, + "auth": [ + "/POST", + "/GET", + "/PUT", + "/PATCH" + ] + } + } + ], + "resourceName": "AccountSettingsApi", + "apiName": "AccountSettingsApi", + "functionArns": [ + { + "lambdaFunction": "AccountSettingsLambda" + } + ], + "privacy": { + "auth": 1, + "unauth": 0, + "authRoleName": "amplify-cleanviewweb-dev-143211-authRole", + "unAuthRoleName": "amplify-cleanviewweb-dev-143211-unauthRole" + }, + "dependsOn": [ + { + "category": "function", + "resourceName": "AccountSettingsLambda", + "attributes": [ + "Name", + "Arn" + ] + } + ] +} \ No newline at end of file diff --git a/amplify/backend/api/AccountSettingsApi/parameters.json b/amplify/backend/api/AccountSettingsApi/parameters.json new file mode 100644 index 0000000..f88dfa2 --- /dev/null +++ b/amplify/backend/api/AccountSettingsApi/parameters.json @@ -0,0 +1,8 @@ +{ + "authRoleName": { + "Ref": "AuthRoleName" + }, + "unauthRoleName": { + "Ref": "UnauthRoleName" + } +} \ No newline at end of file diff --git a/amplify/backend/backend-config.json b/amplify/backend/backend-config.json index 3244dea..ca27638 100644 --- a/amplify/backend/backend-config.json +++ b/amplify/backend/backend-config.json @@ -19,6 +19,10 @@ "LocationStorage": { "service": "S3", "providerPlugin": "awscloudformation" + }, + "accounts": { + "service": "DynamoDB", + "providerPlugin": "awscloudformation" } }, "function": { @@ -97,6 +101,25 @@ } } ] + }, + "AccountSettingsLambda": { + "build": true, + "providerPlugin": "awscloudformation", + "service": "Lambda", + "dependsOn": [ + { + "category": "storage", + "resourceName": "accounts", + "attributes": [ + "Name", + "Arn" + ], + "attributeEnvMap": { + "Name": "TABLE_NAME", + "Arn": "TABLE_ARN" + } + } + ] } }, "api": { @@ -149,6 +172,20 @@ ] } ] + }, + "AccountSettingsApi": { + "service": "API Gateway", + "providerPlugin": "awscloudformation", + "dependsOn": [ + { + "category": "function", + "resourceName": "AccountSettingsLambda", + "attributes": [ + "Name", + "Arn" + ] + } + ] } } } \ No newline at end of file diff --git a/amplify/backend/function/AccountSettingsLambda/AccountSettingsLambda-cloudformation-template.json b/amplify/backend/function/AccountSettingsLambda/AccountSettingsLambda-cloudformation-template.json new file mode 100644 index 0000000..285bd9c --- /dev/null +++ b/amplify/backend/function/AccountSettingsLambda/AccountSettingsLambda-cloudformation-template.json @@ -0,0 +1,220 @@ +{ + "AWSTemplateFormatVersion": "2010-09-09", + "Description": "Lambda Function resource stack creation using Amplify CLI", + "Parameters": { + "CloudWatchRule": { + "Type": "String", + "Default": "NONE", + "Description": " Schedule Expression" + }, + "env": { + "Type": "String" + }, + "storageaccountsName": { + "Type": "String", + "Default": "storageaccountsName" + }, + "storageaccountsArn": { + "Type": "String", + "Default": "storageaccountsArn" + } + }, + "Conditions": { + "ShouldNotCreateEnvResources": { + "Fn::Equals": [ + { + "Ref": "env" + }, + "NONE" + ] + } + }, + "Resources": { + "LambdaFunction": { + "Type": "AWS::Lambda::Function", + "Metadata": { + "aws:asset:path": "./src", + "aws:asset:property": "Code" + }, + "Properties": { + "Handler": "index.handler", + "FunctionName": { + "Fn::If": [ + "ShouldNotCreateEnvResources", + "AccountSettingsLambda", + { + "Fn::Join": [ + "", + [ + "AccountSettingsLambda", + "-", + { + "Ref": "env" + } + ] + ] + } + ] + }, + "Environment": { + "Variables": { + "ENV": { + "Ref": "env" + }, + "REGION": { + "Ref": "AWS::Region" + } + } + }, + "Role": { + "Fn::GetAtt": [ + "LambdaExecutionRole", + "Arn" + ] + }, + "Runtime": "nodejs12.x", + "Layers": [], + "Timeout": "25", + "Code": { + "S3Bucket": "amplify-cleanviewweb-develop-162445-deployment", + "S3Key": "amplify-builds/AccountSettingsLambda-4e6f34627a48316b3471-build.zip" + } + } + }, + "LambdaExecutionRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "RoleName": { + "Fn::If": [ + "ShouldNotCreateEnvResources", + "cleanviewwebLambdaRole52683388", + { + "Fn::Join": [ + "", + [ + "cleanviewwebLambdaRole52683388", + "-", + { + "Ref": "env" + } + ] + ] + } + ] + }, + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": { + "Service": [ + "lambda.amazonaws.com" + ] + }, + "Action": [ + "sts:AssumeRole" + ] + } + ] + } + } + }, + "lambdaexecutionpolicy": { + "DependsOn": [ + "LambdaExecutionRole" + ], + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyName": "lambda-execution-policy", + "Roles": [ + { + "Ref": "LambdaExecutionRole" + } + ], + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "logs:CreateLogGroup", + "logs:CreateLogStream", + "logs:PutLogEvents" + ], + "Resource": { + "Fn::Sub": [ + "arn:aws:logs:${region}:${account}:log-group:/aws/lambda/${lambda}:log-stream:*", + { + "region": { + "Ref": "AWS::Region" + }, + "account": { + "Ref": "AWS::AccountId" + }, + "lambda": { + "Ref": "LambdaFunction" + } + } + ] + } + }, + { + "Effect": "Allow", + "Action": [ + "dynamodb:DescribeTable", + "dynamodb:GetItem", + "dynamodb:Query", + "dynamodb:Scan", + "dynamodb:PutItem", + "dynamodb:UpdateItem", + "dynamodb:DeleteItem" + ], + "Resource": [ + { + "Ref": "storageaccountsArn" + }, + { + "Fn::Join": [ + "/", + [ + { + "Ref": "storageaccountsArn" + }, + "index/*" + ] + ] + } + ] + } + ] + } + } + } + }, + "Outputs": { + "Name": { + "Value": { + "Ref": "LambdaFunction" + } + }, + "Arn": { + "Value": { + "Fn::GetAtt": [ + "LambdaFunction", + "Arn" + ] + } + }, + "Region": { + "Value": { + "Ref": "AWS::Region" + } + }, + "LambdaExecutionRole": { + "Value": { + "Ref": "LambdaExecutionRole" + } + } + } +} \ No newline at end of file diff --git a/amplify/backend/function/AccountSettingsLambda/amplify.state b/amplify/backend/function/AccountSettingsLambda/amplify.state new file mode 100644 index 0000000..2a685b3 --- /dev/null +++ b/amplify/backend/function/AccountSettingsLambda/amplify.state @@ -0,0 +1,6 @@ +{ + "pluginId": "amplify-nodejs-function-runtime-provider", + "functionRuntime": "nodejs", + "useLegacyBuild": true, + "defaultEditorFile": "src/app.js" +} \ No newline at end of file diff --git a/amplify/backend/function/AccountSettingsLambda/function-parameters.json b/amplify/backend/function/AccountSettingsLambda/function-parameters.json new file mode 100644 index 0000000..d507877 --- /dev/null +++ b/amplify/backend/function/AccountSettingsLambda/function-parameters.json @@ -0,0 +1,3 @@ +{ + "lambdaLayers": [] +} \ No newline at end of file diff --git a/amplify/backend/function/AccountSettingsLambda/parameters.json b/amplify/backend/function/AccountSettingsLambda/parameters.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/amplify/backend/function/AccountSettingsLambda/parameters.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/amplify/backend/function/AccountSettingsLambda/src/app.js b/amplify/backend/function/AccountSettingsLambda/src/app.js new file mode 100644 index 0000000..cc214ce --- /dev/null +++ b/amplify/backend/function/AccountSettingsLambda/src/app.js @@ -0,0 +1,211 @@ +/* +Copyright 2017 - 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. +Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at + http://aws.amazon.com/apache2.0/ +or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and limitations under the License. +*/ + +const AWS = require('aws-sdk') +var awsServerlessExpressMiddleware = require('aws-serverless-express/middleware') +var bodyParser = require('body-parser') +var express = require('express') + +AWS.config.update({ region: process.env.TABLE_REGION }); + +const dynamodb = new AWS.DynamoDB.DocumentClient(); + +let tableName = "accounts"; +if(process.env.ENV && process.env.ENV !== "NONE") { + tableName = tableName + '-' + process.env.ENV; +} + +const userIdPresent = false; // TODO: update in case is required to use that definition +const partitionKeyName = "id"; +const partitionKeyType = "S"; +const sortKeyName = ""; +const sortKeyType = ""; +const hasSortKey = sortKeyName !== ""; +const path = "/account"; +const UNAUTH = 'UNAUTH'; +const hashKeyPath = '/:' + partitionKeyName; +const sortKeyPath = hasSortKey ? '/:' + sortKeyName : ''; +// declare a new express app +var app = express() +app.use(bodyParser.json()) +app.use(awsServerlessExpressMiddleware.eventContext()) + +// Enable CORS for all methods +app.use(function(req, res, next) { + res.header("Access-Control-Allow-Origin", "*") + res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept") + next() +}); + +// convert url string param to expected Type +const convertUrlType = (param, type) => { + switch(type) { + case "N": + return Number.parseInt(param); + default: + return param; + } +} + +/***************************************** + * HTTP Get method for get single account by ID * + *****************************************/ + +app.get(path + '/manager', function(req, res) { + let getItemParams = { + TableName: tableName, + Key: {"id": req.query.id}, + }; + + dynamodb.get(getItemParams,(err, data) => { + if(err) { + res.statusCode = 500; + res.json({error: 'Could not load items: ' + err.message}); + } else { + if (data.Item) { + res.json(data.Item); + } else { + res.json(data) ; + } + } + }); +}); + + +/************************************ +* HTTP put method for insert object * +*************************************/ + +app.put(path, function(req, res) { + + if (userIdPresent) { + req.body['userId'] = req.apiGateway.event.requestContext.identity.cognitoIdentityId || UNAUTH; + } + + let putItemParams = { + TableName: tableName, + Item: req.body + } + dynamodb.put(putItemParams, (err, data) => { + if(err) { + res.statusCode = 500; + res.json({error: err, url: req.url, body: req.body}); + } else{ + res.json({success: 'put call succeed!', url: req.url, data: data}) + } + }); +}); + +/************************************ +* HTTP post method for insert object * +*************************************/ + +app.post(path, function(req, res) { + + if (userIdPresent) { + req.body['userId'] = req.apiGateway.event.requestContext.identity.cognitoIdentityId || UNAUTH; + } + + let putItemParams = { + TableName: tableName, + Item: req.body + } + dynamodb.put(putItemParams, (err, data) => { + if(err) { + res.statusCode = 500; + res.json({error: err, url: req.url, body: req.body}); + } else{ + res.json({success: 'post call succeed!', url: req.url, data: data}) + } + }); +}); + +/************************************** +* HTTP remove method to delete object * +***************************************/ + +app.delete(path + '/object' + hashKeyPath + sortKeyPath, function(req, res) { + var params = {}; + if (userIdPresent && req.apiGateway) { + params[partitionKeyName] = req.apiGateway.event.requestContext.identity.cognitoIdentityId || UNAUTH; + } else { + params[partitionKeyName] = req.params[partitionKeyName]; + try { + params[partitionKeyName] = convertUrlType(req.params[partitionKeyName], partitionKeyType); + } catch(err) { + res.statusCode = 500; + res.json({error: 'Wrong column type ' + err}); + } + } + if (hasSortKey) { + try { + params[sortKeyName] = convertUrlType(req.params[sortKeyName], sortKeyType); + } catch(err) { + res.statusCode = 500; + res.json({error: 'Wrong column type ' + err}); + } + } + + let removeItemParams = { + TableName: tableName, + Key: params + } + dynamodb.delete(removeItemParams, (err, data)=> { + if(err) { + res.statusCode = 500; + res.json({error: err, url: req.url}); + } else { + res.json({url: req.url, data: data}); + } + }); +}); +app.listen(3000, function() { + console.log("App started") +}); + +/** + * Patch Request for Individual Acct + */ + +app.patch(path + '/manager', function(req, res) { + if (userIdPresent) { + req.body["userId"] = + req.apiGateway.event.requestContext.identity.cognitoIdentityId || UNAUTH; + } + + var params = { + TableName: tableName, + Key: { + "id": req.body.id + }, + UpdateExpression: "set email = :EM, username = :UN, firstName = :FN, lastName = :LN, phone = :PH", + ExpressionAttributeValues: { + ":EM": req.body.email, + ":UN": req.body.username, + ":FN": req.body.firstName, + ":LN": req.body.lastName, + ":PH": req.body.phone, + }, + ReturnValues:"UPDATED_NEW" + } + + dynamodb.update(params, function(err, data) { + if (err) { + res.statusCode = 500; + res.json({ error: err, url: req.url, body: req.body}); + } else { + res.json({ success: "patch call succeed!", url: req.url, data: data }); + } + }); + +}); + +// Export the app object. When executing the application local this does nothing. However, +// to port it to AWS Lambda we will create a wrapper around that will load the app from +// this file +module.exports = app diff --git a/amplify/backend/function/AccountSettingsLambda/src/event.json b/amplify/backend/function/AccountSettingsLambda/src/event.json new file mode 100644 index 0000000..fd2722e --- /dev/null +++ b/amplify/backend/function/AccountSettingsLambda/src/event.json @@ -0,0 +1,5 @@ +{ + "key1": "value1", + "key2": "value2", + "key3": "value3" +} diff --git a/amplify/backend/function/AccountSettingsLambda/src/index.js b/amplify/backend/function/AccountSettingsLambda/src/index.js new file mode 100644 index 0000000..c0827eb --- /dev/null +++ b/amplify/backend/function/AccountSettingsLambda/src/index.js @@ -0,0 +1,9 @@ +const awsServerlessExpress = require('aws-serverless-express'); +const app = require('./app'); + +const server = awsServerlessExpress.createServer(app); + +exports.handler = (event, context) => { + console.log(`EVENT: ${JSON.stringify(event)}`); + return awsServerlessExpress.proxy(server, event, context, 'PROMISE').promise; +}; diff --git a/amplify/backend/function/AccountSettingsLambda/src/package-lock.json b/amplify/backend/function/AccountSettingsLambda/src/package-lock.json new file mode 100644 index 0000000..1ee35cb --- /dev/null +++ b/amplify/backend/function/AccountSettingsLambda/src/package-lock.json @@ -0,0 +1,482 @@ +{ + "name": "AccountSettingsLambda", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "accepts": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", + "requires": { + "mime-types": "~2.1.24", + "negotiator": "0.6.2" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "aws-sdk": { + "version": "2.725.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.725.0.tgz", + "integrity": "sha512-Qd/MlxfQC9NpTxFUQ7u2BdsjiwNtbn5oVp04NPfXEc0xyT216TtcIs+jNyiJ9WaH7AgkHouU1BbBcReO8byYzg==", + "requires": { + "buffer": "4.9.2", + "events": "1.1.1", + "ieee754": "1.1.13", + "jmespath": "0.15.0", + "querystring": "0.2.0", + "sax": "1.2.1", + "url": "0.10.3", + "uuid": "3.3.2", + "xml2js": "0.4.19" + } + }, + "aws-serverless-express": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/aws-serverless-express/-/aws-serverless-express-3.3.8.tgz", + "integrity": "sha512-2TQdF5EhxnAtGeEi+wSi2M3xCfpiemuImnpU7HKih3onH0izJ/G2tkM+gwcGHZEsW/gLWFl/JjQAYGa3fILfvw==", + "requires": { + "binary-case": "^1.0.0", + "type-is": "^1.6.16" + } + }, + "base64-js": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", + "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==" + }, + "binary-case": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/binary-case/-/binary-case-1.1.4.tgz", + "integrity": "sha512-9Kq8m6NZTAgy05Ryuh7U3Qc4/ujLQU1AZ5vMw4cr3igTdi5itZC6kCNrRr2X8NzPiDn2oUIFTfa71DKMnue/Zg==" + }, + "body-parser": { + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", + "requires": { + "bytes": "3.1.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "on-finished": "~2.3.0", + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + } + }, + "buffer": { + "version": "4.9.2", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz", + "integrity": "sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==", + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4", + "isarray": "^1.0.0" + } + }, + "bytes": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" + }, + "content-disposition": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", + "requires": { + "safe-buffer": "5.1.2" + } + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", + "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "events": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", + "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=" + }, + "express": { + "version": "4.17.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", + "requires": { + "accepts": "~1.3.7", + "array-flatten": "1.1.1", + "body-parser": "1.19.0", + "content-disposition": "0.5.3", + "content-type": "~1.0.4", + "cookie": "0.4.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.1.2", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.5", + "qs": "6.7.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.1.2", + "send": "0.17.1", + "serve-static": "1.14.1", + "setprototypeof": "1.1.1", + "statuses": "~1.5.0", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + } + }, + "finalhandler": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.3", + "statuses": "~1.5.0", + "unpipe": "~1.0.0" + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "http-errors": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" + } + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ieee754": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "jmespath": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", + "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=" + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + }, + "mime-db": { + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", + "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==" + }, + "mime-types": { + "version": "2.1.27", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", + "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", + "requires": { + "mime-db": "1.44.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "negotiator": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "proxy-addr": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", + "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.9.1" + } + }, + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" + }, + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" + }, + "querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" + }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" + }, + "raw-body": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", + "requires": { + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "sax": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", + "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=" + }, + "send": { + "version": "0.17.1", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", + "on-finished": "~2.3.0", + "range-parser": "~1.2.1", + "statuses": "~1.5.0" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } + } + }, + "serve-static": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.17.1" + } + }, + "setprototypeof": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" + }, + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" + }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" + }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "url": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", + "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=", + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + } + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, + "xml2js": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", + "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", + "requires": { + "sax": ">=0.6.0", + "xmlbuilder": "~9.0.1" + } + }, + "xmlbuilder": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" + } + } +} diff --git a/amplify/backend/function/AccountSettingsLambda/src/package.json b/amplify/backend/function/AccountSettingsLambda/src/package.json new file mode 100644 index 0000000..ca6225f --- /dev/null +++ b/amplify/backend/function/AccountSettingsLambda/src/package.json @@ -0,0 +1,18 @@ +{ + "name": "AccountSettingsLambda", + "version": "1.0.0", + "description": "", + "main": "index.js", + "dependencies": { + "aws-sdk": "^2.580.0", + "aws-serverless-express": "^3.3.5", + "body-parser": "^1.17.1", + "express": "^4.15.2" + }, + "devDependencies": {}, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +} diff --git a/amplify/backend/function/CreateSurveyLambda/CreateSurveyLambda-cloudformation-template.json b/amplify/backend/function/CreateSurveyLambda/CreateSurveyLambda-cloudformation-template.json index cc8d973..aa217f0 100644 --- a/amplify/backend/function/CreateSurveyLambda/CreateSurveyLambda-cloudformation-template.json +++ b/amplify/backend/function/CreateSurveyLambda/CreateSurveyLambda-cloudformation-template.json @@ -76,8 +76,8 @@ "Layers": [], "Timeout": "25", "Code": { - "S3Bucket": "amplify-cleanviewweb-dev-143211-deployment", - "S3Key": "amplify-builds/CreateSurveyLambda-51766f6567374a742f62-build.zip" + "S3Bucket": "amplify-cleanviewweb-develop-162445-deployment", + "S3Key": "amplify-builds/CreateSurveyLambda-626a4e59466c312b7754-build.zip" } } }, diff --git a/amplify/backend/function/CreateSurveyLambda/src/app.js b/amplify/backend/function/CreateSurveyLambda/src/app.js index d2ac267..9ad0f59 100644 --- a/amplify/backend/function/CreateSurveyLambda/src/app.js +++ b/amplify/backend/function/CreateSurveyLambda/src/app.js @@ -32,6 +32,8 @@ const dynamodb = new AWS.DynamoDB.DocumentClient(); let environmentURL = "https://d9uqja1id6.execute-api.us-east-1.amazonaws.com/dev" if(process.ENV === 'dev') { environmentURL = "https://d9uqja1id6.execute-api.us-east-1.amazonaws.com/dev" +} else if(process.env.ENV === 'develop') { + environmentURL = "https://tsro629xid.execute-api.us-east-1.amazonaws.com/develop" } else if(process.env.ENV === 'staging') { environmentURL = "https://n4ye0be6kd.execute-api.us-east-1.amazonaws.com/staging" } else if(process.env.ENV === 'prod') { @@ -132,14 +134,20 @@ app.get("/survey/:id", function (req, res) { font-size: 16px; margin: 15px 0px 5px 0px; } + + .age-selector{ + justify-items: center; + align-items: center; + } .selection-button { /* Button design */ background-color: #ffffff; border-radius: 10px; + position: relative; display: inline-block; cursor: pointer; - width: 55px; + width: 58px; /* Text properties */ color: #666666; @@ -155,6 +163,38 @@ app.get("/survey/:id", function (req, res) { background: linear-gradient(to bottom, #f6f6f6 5%, #ffffff 100%); background-color: #f6f6f6; } + + #under-12 { + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + + /* Button design */ + border: none; + background-color: #ffffff; + border-radius: 10px; + position: relative; + display: inline-block; + cursor: pointer; + width: 79px; + + /* Text properties */ + color: #666666; + font-size: 12px; + font-weight: 150px; + padding: 9px 5px; + text-align: center; + + /* Buttons which wrap to the next line will have spacing between top line */ + margin: 0px 0px 10px 0px; + } + + #under-12:hover { + background: linear-gradient(to bottom, #f6f6f6 5%, #ffffff 100%); + background-color: #f6f6f6; + } + + amp-selector [option][selected] { outline: 0px; @@ -164,7 +204,7 @@ app.get("/survey/:id", function (req, res) { position: relative; } - input[type="submit"] { + #submission { -webkit-appearance: none; -moz-appearance: none; appearance: none; @@ -187,11 +227,11 @@ app.get("/survey/:id", function (req, res) { margin: 0px 0px 10px 0px; } - input[type="submit"]:hover { + #submission:hover { background-color: #119c84; } - input[type="submit"]:active { + #submission:active { outline: 0px; background: #119c84; font-weight: normal; @@ -336,7 +376,8 @@ app.get("/survey/:id", function (req, res) { selectedOption: event.targetOption, allSelectedOptions: event.selectedOptions })'> -
+ + @@ -358,12 +399,13 @@ app.get("/survey/:id", function (req, res) {How satisfied are you with ${name}'s overall COVID-19 response?
- + +