From 8eef94301374ceecb1e4ff42acdd3eaada56125f Mon Sep 17 00:00:00 2001 From: Gagan Tunuguntla Date: Sat, 7 Dec 2019 14:51:06 -0500 Subject: [PATCH] Update with more organized api code --- .gitignore | 1 + api/requirements.txt | 2 + api/sheet/_code_/app.py | 125 ------------------ api/src/__core__/authentication_middleware.py | 10 ++ api/src/__core__/json_parsing_middleware.py | 5 + api/src/__core__/settings.py | 20 +++ api/src/__core__/utilities.py | 22 +++ api/src/__init__.py | 1 + api/src/app.py | 35 +++++ api/src/sheet/__init__.py | 73 ++++++++++ .../sheet/{sheetName}/__init__.py} | 69 ++-------- api/standup-api.sh | 3 + api/template.yaml | 28 ++-- docker-compose.yml | 2 +- 14 files changed, 197 insertions(+), 199 deletions(-) create mode 100644 api/requirements.txt delete mode 100644 api/sheet/_code_/app.py create mode 100644 api/src/__core__/authentication_middleware.py create mode 100644 api/src/__core__/json_parsing_middleware.py create mode 100644 api/src/__core__/settings.py create mode 100644 api/src/__core__/utilities.py create mode 100644 api/src/__init__.py create mode 100644 api/src/app.py create mode 100644 api/src/sheet/__init__.py rename api/{sheet/{sheetName}/_code_/app.py => src/sheet/{sheetName}/__init__.py} (60%) diff --git a/.gitignore b/.gitignore index d6f0b16..2caaadd 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ api/dependencies/* api/notebooks api/cached-dependencies archived-services +__dependencies__ # CLIENT UI Ignores client-ui/angular-output/* diff --git a/api/requirements.txt b/api/requirements.txt new file mode 100644 index 0000000..66f55b2 --- /dev/null +++ b/api/requirements.txt @@ -0,0 +1,2 @@ +pyjwt==1.7.1 +cryptography==2.8 diff --git a/api/sheet/_code_/app.py b/api/sheet/_code_/app.py deleted file mode 100644 index 88dc925..0000000 --- a/api/sheet/_code_/app.py +++ /dev/null @@ -1,125 +0,0 @@ -import boto3 -import json -import datetime -from boto3 import client -s3_client = client('s3') - -available_file_types = [ - 'abap', 'abc', 'actionscript', 'ada', 'apache_conf', 'apex', 'applescript', 'asciidoc', 'asl', - 'assembly_x86', 'autohotkey', 'batchfile', 'bro', 'c9search', 'c_cpp', 'cirru', 'clojure', 'cobol', - 'coffee', 'coldfusion', 'csharp', 'csound_document', 'csound_orchestra', 'csound_score', 'csp', 'css', - 'curly', 'd', 'dart', 'diff', 'django', 'dockerfile', 'dot', 'drools', 'edifact', 'eiffel', 'ejs', - 'elixir', 'elm', 'erlang', 'forth', 'fortran', 'fsharp', 'fsl', 'ftl', 'gcode', 'gherkin', 'gitignore', - 'glsl', 'gobstones', 'golang', 'graphqlschema', 'groovy', 'haml', 'handlebars', 'haskell', - 'haskell_cabal', 'haxe', 'hjson', 'html', 'html_elixir', 'html_ruby', 'ini', 'io', 'jack', 'jade', 'java', - 'javascript', 'json', 'jsoniq', 'jsp', 'jssm', 'jsx', 'julia', 'kotlin', 'latex', 'less', 'liquid', - 'lisp', 'livescript', 'logiql', 'logtalk', 'lsl', 'lua', 'luapage', 'lucene', 'makefile', 'markdown', - 'mask', 'matlab', 'maze', 'mel', 'mixal', 'mushcode', 'mysql', 'nix', 'nsis', 'objectivec', 'ocaml', - 'pascal', 'perl', 'perl6', 'pgsql', 'php', 'php_laravel_blade', 'pig', 'plain_text', 'powershell', - 'praat', 'prolog', 'properties', 'protobuf', 'puppet', 'python', 'r', 'razor', 'rdoc', 'red', 'redshift', - 'rhtml', 'rst', 'ruby', 'rust', 'sass', 'scad', 'scala', 'scheme', 'scss', 'sh', 'sjs', 'slim', 'smarty', - 'snippets', 'soy_template', 'space', 'sparql', 'sql', 'sqlserver', 'stylus', 'svg', 'swift', 'tcl', - 'terraform', 'tex', 'text', 'textile', 'toml', 'tsx', 'turtle', 'twig', 'typescript', 'vala', 'vbscript', - 'velocity', 'verilog', 'vhdl', 'visualforce', 'wollok', 'xml', 'xquery', 'yaml' -] - -new_sheet = { - "defaultFileType": None, - "dateCreated": datetime.datetime.now().timestamp(), - "dateUpdated": datetime.datetime.now().timestamp(), - "leftIndexCards": [ - ], - "rightIndexCards": [ - ] -} - -user='default' -cheetsheet_bucket_name='scratch-cheetsheet-storage' - -s3_get_sheet_names_response = s3_client.list_objects( - Bucket = cheetsheet_bucket_name, - Prefix = f'{user}/', - Delimiter = '/' -)['CommonPrefixes'] -all_current_sheet_names = [obj['Prefix'][(len(user)+1):-1] for obj in s3_get_sheet_names_response] - - -def get(event, context): - """ - Get All Sheets - """ - return { - "statusCode": 200, - "body": json.dumps({ - 'result': { - 'sheetNames': all_current_sheet_names - } - }) - } - -def post(event, context): - """ - Create A New Sheet - """ - - if 'sheetName' not in event['body'] or event['body']['sheetName'] is None: - # Error if no sheet name was provided - return get_error_response('No name for sheet was provided') - - if event['body']['sheetName'] in all_current_sheet_names: - # Error if sheet name exists - return get_error_response(f'Sheet with name {event["body"]["sheetName"]} already exists') - - if 'defaultFileType' not in event['body'] or event['body']['sheetName'] is None: - # Error if Default File type was not provided - return get_error_response('No Default File Type was provided') - - if event['body']['defaultFileType'] not in available_file_types: - # Error if Default File type is not supported - return get_error_response(f'Default file type {event["body"]["defaultFileType"]} is not supported') - - # Create Empty sheet in S3 bucket - new_sheet['defaultFileType'] = event['body']['defaultFileType'] - s3_client.put_object( - ACL='private', - Body = (bytes(json.dumps(new_sheet).encode('UTF-8'))), - Bucket = cheetsheet_bucket_name, - Key=f'{user}/{event["body"]["sheetName"]}/sheet.json' - - ) - - return { - "statusCode": 200, - "body": json.dumps({ - 'results': { - 'sheetName': event["body"]["sheetName"], - 'sheetData': new_sheet - } - }) - } - -def main(event, context): - if event["httpMethod"] == "GET": - response = get(event, context) - elif event["httpMethod"] == "POST": - response = post(event, context) - else: - response = { - "statusCode": 405, - "body": json.dumps({ - "message": "Method Not Allowed" - }) - } - response["headers"] = {'Access-Control-Allow-Origin': "*"} - return response - - -# Helper Methods -def get_error_response(message, statusCode=400): - return { - 'statusCode': statusCode, - 'body': json.dumps({ - 'message': message - }), - 'headers': {'Access-Control-Allow-Origin': "*"} - } diff --git a/api/src/__core__/authentication_middleware.py b/api/src/__core__/authentication_middleware.py new file mode 100644 index 0000000..85fb704 --- /dev/null +++ b/api/src/__core__/authentication_middleware.py @@ -0,0 +1,10 @@ +from __dependencies__ import jwt + +def apply(event): + headers = event['headers'] + algorithm = 'RS256' + token = "eyJraWQiOiJVVTRHTmZ4WXJTOXlCQXFGdnpJVUNTQ2YxZWcwcUpRaFwvSHg2dGZiUW00UT0iLCJhbGciOiJSUzI1NiJ9.eyJhdF9oYXNoIjoiWm5iYnRqdFdSNDVZbm1yWVZ3UkFUUSIsInN1YiI6IjQ4ZTZiNDdlLTllYjUtNDI3OC04NTUzLTFkZGNhYmM2OTQ2ZiIsImF1ZCI6IjEzcjZrOWE5NHZvNDBwcWE4M2NkbWhvbWptIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImV2ZW50X2lkIjoiZGJjN2UzY2ItNWZiYS00ZGM1LWEyYjEtOGE5M2VhZDE2OGQyIiwidG9rZW5fdXNlIjoiaWQiLCJhdXRoX3RpbWUiOjE1NzU2ODA2OTksImlzcyI6Imh0dHBzOlwvXC9jb2duaXRvLWlkcC51cy1lYXN0LTEuYW1hem9uYXdzLmNvbVwvdXMtZWFzdC0xX01abG4zeXpLbiIsImNvZ25pdG86dXNlcm5hbWUiOiJHdWd6IiwiZXhwIjoxNTc1Njg0Mjk5LCJpYXQiOjE1NzU2ODA2OTksImVtYWlsIjoiZ2FnYW50dW51Z3VudGxhQHNhaW1haWwuY29tIn0.KJ2_S7siRtnl4RItwwBrJbVZtcR37a25jMhK1MzagSdAG5E6eWy3uhNgggiKBWlDIw3KYVhFnaAPqsGJPyU2m6i9Q6Cpeb3bXKpVAgW0KQUaQd8PX2AYxzR46kwahqay0gfXH2fywODK_mWOYNjr2njW0WINiG74bVNYxNG0mZ4_UREK39UEDlApLtWWHcFghYytY5b0Wl2nLv7UQjAcbVHaafZ1EyzcpbqdB_nEMsCHRXiGQmKmXGHa6LNAtEWCbDYcY1UAoMyC3RhFwdT5gy_gx55G5VTNolwVAl34azd4DqZelaTcR_C4lWZwXipWlJzXA4eBWCEuX5rSZRHsQw" + jwt.decode(token, 'secret', algorithms=[algorithm]) + if ('Authorization' in headers) and (headers['Authorization']): + jwt_token = headers['Authorization'] + print(jwt_token) diff --git a/api/src/__core__/json_parsing_middleware.py b/api/src/__core__/json_parsing_middleware.py new file mode 100644 index 0000000..bfdbb0a --- /dev/null +++ b/api/src/__core__/json_parsing_middleware.py @@ -0,0 +1,5 @@ +import json + +def apply(event): + if ('body' in event) and (event['body']): + event['body'] = json.loads(event['body']) diff --git a/api/src/__core__/settings.py b/api/src/__core__/settings.py new file mode 100644 index 0000000..d7bb6a4 --- /dev/null +++ b/api/src/__core__/settings.py @@ -0,0 +1,20 @@ +AVAILABLE_FILE_TYPES = [ + 'abap', 'abc', 'actionscript', 'ada', 'apache_conf', 'apex', 'applescript', 'asciidoc', 'asl', + 'assembly_x86', 'autohotkey', 'batchfile', 'bro', 'c9search', 'c_cpp', 'cirru', 'clojure', 'cobol', + 'coffee', 'coldfusion', 'csharp', 'csound_document', 'csound_orchestra', 'csound_score', 'csp', 'css', + 'curly', 'd', 'dart', 'diff', 'django', 'dockerfile', 'dot', 'drools', 'edifact', 'eiffel', 'ejs', + 'elixir', 'elm', 'erlang', 'forth', 'fortran', 'fsharp', 'fsl', 'ftl', 'gcode', 'gherkin', 'gitignore', + 'glsl', 'gobstones', 'golang', 'graphqlschema', 'groovy', 'haml', 'handlebars', 'haskell', + 'haskell_cabal', 'haxe', 'hjson', 'html', 'html_elixir', 'html_ruby', 'ini', 'io', 'jack', 'jade', 'java', + 'javascript', 'json', 'jsoniq', 'jsp', 'jssm', 'jsx', 'julia', 'kotlin', 'latex', 'less', 'liquid', + 'lisp', 'livescript', 'logiql', 'logtalk', 'lsl', 'lua', 'luapage', 'lucene', 'makefile', 'markdown', + 'mask', 'matlab', 'maze', 'mel', 'mixal', 'mushcode', 'mysql', 'nix', 'nsis', 'objectivec', 'ocaml', + 'pascal', 'perl', 'perl6', 'pgsql', 'php', 'php_laravel_blade', 'pig', 'plain_text', 'powershell', + 'praat', 'prolog', 'properties', 'protobuf', 'puppet', 'python', 'r', 'razor', 'rdoc', 'red', 'redshift', + 'rhtml', 'rst', 'ruby', 'rust', 'sass', 'scad', 'scala', 'scheme', 'scss', 'sh', 'sjs', 'slim', 'smarty', + 'snippets', 'soy_template', 'space', 'sparql', 'sql', 'sqlserver', 'stylus', 'svg', 'swift', 'tcl', + 'terraform', 'tex', 'text', 'textile', 'toml', 'tsx', 'turtle', 'twig', 'typescript', 'vala', 'vbscript', + 'velocity', 'verilog', 'vhdl', 'visualforce', 'wollok', 'xml', 'xquery', 'yaml' +] +SHEET_DATA_S3_BUCKET='scratch-cheetsheet-storage' +ADMIN_USER='default' diff --git a/api/src/__core__/utilities.py b/api/src/__core__/utilities.py new file mode 100644 index 0000000..b47fb77 --- /dev/null +++ b/api/src/__core__/utilities.py @@ -0,0 +1,22 @@ +import json +import datetime + +def get_a_blank_new_sheet(): + return { + "defaultFileType": None, + "dateCreated": datetime.datetime.now().timestamp(), + "dateUpdated": datetime.datetime.now().timestamp(), + "leftIndexCards": [ + ], + "rightIndexCards": [ + ] + } + +def get_error_response(message, statusCode=400): + return { + 'statusCode': statusCode, + 'body': json.dumps({ + 'message': message + }), + 'headers': {'Access-Control-Allow-Origin': "*"} + } diff --git a/api/src/__init__.py b/api/src/__init__.py new file mode 100644 index 0000000..ff19d53 --- /dev/null +++ b/api/src/__init__.py @@ -0,0 +1 @@ +# Leave This File Empty diff --git a/api/src/app.py b/api/src/app.py new file mode 100644 index 0000000..774a791 --- /dev/null +++ b/api/src/app.py @@ -0,0 +1,35 @@ +import json +import importlib +import sys +from __core__ import authentication_middleware, json_parsing_middleware +# sys.path.append("./__dependencies__") + + +def main(event, context): + # Extract htttp information from the endpoint + api_resource_path = event["resource"] + api_http_method = event["httpMethod"].lower() + + # Apply middleware + authentication_middleware.apply(event) + json_parsing_middleware.apply(event) + + # Load the correct python module for the api endpoint + api_resource_path = event["resource"] + spec = importlib.util.spec_from_file_location("module.name", f'./{api_resource_path}/__init__.py') + endpoint_module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(endpoint_module) + + # Check if the method belongs to the module + if api_http_method not in dir(endpoint_module): + return { + "statusCode": 405, + "body": json.dumps({ + "message": "Method Not Allowed" + }) + } + + # Return desired result of api endpoint + response = getattr(endpoint_module, api_http_method)(event, context) + response["headers"] = {'Access-Control-Allow-Origin': "*"} + return response diff --git a/api/src/sheet/__init__.py b/api/src/sheet/__init__.py new file mode 100644 index 0000000..7b879c7 --- /dev/null +++ b/api/src/sheet/__init__.py @@ -0,0 +1,73 @@ +""" +API methods for /sheet +""" +import boto3 +import json +import datetime +from boto3 import client +s3_client = client('s3') +from __core__.settings import AVAILABLE_FILE_TYPES, SHEET_DATA_S3_BUCKET, ADMIN_USER +from __core__.utilities import get_a_blank_new_sheet, get_error_response + +user = ADMIN_USER +s3_get_sheet_names_response = s3_client.list_objects( + Bucket = SHEET_DATA_S3_BUCKET, + Prefix = f'{user}/', + Delimiter = '/' +)['CommonPrefixes'] +all_current_sheet_names = [obj['Prefix'][(len(user)+1):-1] for obj in s3_get_sheet_names_response] + +def get(event, context): + """ + Get All Sheets + """ + return { + "statusCode": 200, + "body": json.dumps({ + 'result': { + 'sheetNames': all_current_sheet_names + } + }) + } + +def post(event, context): + """ + Create A New Sheet + """ + + if 'sheetName' not in event['body'] or event['body']['sheetName'] is None: + # Error if no sheet name was provided + return get_error_response('No name for sheet was provided') + + if event['body']['sheetName'] in all_current_sheet_names: + # Error if sheet name exists + return get_error_response(f'Sheet with name {event["body"]["sheetName"]} already exists') + + if 'defaultFileType' not in event['body'] or event['body']['sheetName'] is None: + # Error if Default File type was not provided + return get_error_response('No Default File Type was provided') + + if event['body']['defaultFileType'] not in AVAILABLE_FILE_TYPES: + # Error if Default File type is not supported + return get_error_response(f'Default file type {event["body"]["defaultFileType"]} is not supported') + + # Create Empty sheet in S3 bucket + new_sheet = get_a_blank_new_sheet() + new_sheet['defaultFileType'] = event['body']['defaultFileType'] + s3_client.put_object( + ACL='private', + Body = (bytes(json.dumps(new_sheet).encode('UTF-8'))), + Bucket = cheetsheet_bucket_name, + Key=f'{user}/{event["body"]["sheetName"]}/sheet.json' + + ) + + return { + "statusCode": 200, + "body": json.dumps({ + 'results': { + 'sheetName': event["body"]["sheetName"], + 'sheetData': new_sheet + } + }) + } diff --git a/api/sheet/{sheetName}/_code_/app.py b/api/src/sheet/{sheetName}/__init__.py similarity index 60% rename from api/sheet/{sheetName}/_code_/app.py rename to api/src/sheet/{sheetName}/__init__.py index 475c029..030d01c 100644 --- a/api/sheet/{sheetName}/_code_/app.py +++ b/api/src/sheet/{sheetName}/__init__.py @@ -1,39 +1,22 @@ +""" +API methods for /sheet/{sheetName} +""" import boto3 import json import datetime from boto3 import client s3_client = client('s3') +from __core__.settings import AVAILABLE_FILE_TYPES, SHEET_DATA_S3_BUCKET, ADMIN_USER +from __core__.utilities import get_a_blank_new_sheet, get_error_response -available_file_types = [ - 'abap', 'abc', 'actionscript', 'ada', 'apache_conf', 'apex', 'applescript', 'asciidoc', 'asl', - 'assembly_x86', 'autohotkey', 'batchfile', 'bro', 'c9search', 'c_cpp', 'cirru', 'clojure', 'cobol', - 'coffee', 'coldfusion', 'csharp', 'csound_document', 'csound_orchestra', 'csound_score', 'csp', 'css', - 'curly', 'd', 'dart', 'diff', 'django', 'dockerfile', 'dot', 'drools', 'edifact', 'eiffel', 'ejs', - 'elixir', 'elm', 'erlang', 'forth', 'fortran', 'fsharp', 'fsl', 'ftl', 'gcode', 'gherkin', 'gitignore', - 'glsl', 'gobstones', 'golang', 'graphqlschema', 'groovy', 'haml', 'handlebars', 'haskell', - 'haskell_cabal', 'haxe', 'hjson', 'html', 'html_elixir', 'html_ruby', 'ini', 'io', 'jack', 'jade', 'java', - 'javascript', 'json', 'jsoniq', 'jsp', 'jssm', 'jsx', 'julia', 'kotlin', 'latex', 'less', 'liquid', - 'lisp', 'livescript', 'logiql', 'logtalk', 'lsl', 'lua', 'luapage', 'lucene', 'makefile', 'markdown', - 'mask', 'matlab', 'maze', 'mel', 'mixal', 'mushcode', 'mysql', 'nix', 'nsis', 'objectivec', 'ocaml', - 'pascal', 'perl', 'perl6', 'pgsql', 'php', 'php_laravel_blade', 'pig', 'plain_text', 'powershell', - 'praat', 'prolog', 'properties', 'protobuf', 'puppet', 'python', 'r', 'razor', 'rdoc', 'red', 'redshift', - 'rhtml', 'rst', 'ruby', 'rust', 'sass', 'scad', 'scala', 'scheme', 'scss', 'sh', 'sjs', 'slim', 'smarty', - 'snippets', 'soy_template', 'space', 'sparql', 'sql', 'sqlserver', 'stylus', 'svg', 'swift', 'tcl', - 'terraform', 'tex', 'text', 'textile', 'toml', 'tsx', 'turtle', 'twig', 'typescript', 'vala', 'vbscript', - 'velocity', 'verilog', 'vhdl', 'visualforce', 'wollok', 'xml', 'xquery', 'yaml' -] - -user='default' -cheetsheet_bucket_name='scratch-cheetsheet-storage' - +user = ADMIN_USER s3_get_sheet_names_response = s3_client.list_objects( - Bucket = cheetsheet_bucket_name, + Bucket = SHEET_DATA_S3_BUCKET, Prefix = f'{user}/', Delimiter = '/' )['CommonPrefixes'] all_current_sheet_names = [obj['Prefix'][(len(user)+1):-1] for obj in s3_get_sheet_names_response] - def get(event, context): """ Get JSON data of a sheet @@ -47,7 +30,7 @@ def get(event, context): return get_error_response(f'No sheet with name {event["pathParameters"]["sheetName"]} exists') s3_get_sheet_response = s3_client.get_object( - Bucket=cheetsheet_bucket_name, + Bucket=SHEET_DATA_S3_BUCKET, Key=f'{user}/{event["pathParameters"]["sheetName"]}/sheet.json' ) sheet_data = json.loads(s3_get_sheet_response["Body"].read().decode()) @@ -76,7 +59,7 @@ def delete(event, context): # Delete sheet in S3 bucket s3_delete_sheet_response = s3_client.delete_object( - Bucket = cheetsheet_bucket_name, + Bucket = SHEET_DATA_S3_BUCKET, Key=f'{user}/{event["pathParameters"]["sheetName"]}/sheet.json' ) @@ -94,6 +77,7 @@ def put(event, context): """ Update an existing sheet """ + print(type(event['body'])) if 'sheetName' not in event['pathParameters'] or event['pathParameters']['sheetName'] is None: # Error if no sheet name was provided return get_error_response('No name for sheet was provided') @@ -106,7 +90,7 @@ def put(event, context): new_sheet_data = event['body']['sheetData'] - if new_sheet_data['defaultFileType'] not in available_file_types: + if new_sheet_data['defaultFileType'] not in AVAILABLE_FILE_TYPES: # Error if Default File type is not supported return get_error_response( f'Default file type {event["body"]["sheetData"]["defaultFileType"]} is not supported' @@ -119,7 +103,7 @@ def put(event, context): # Get current data for sheet s3_get_sheet_response = s3_client.get_object( - Bucket=cheetsheet_bucket_name, + Bucket=SHEET_DATA_S3_BUCKET, Key=f'{user}/{event["pathParameters"]["sheetName"]}/sheet.json' ) sheet_data = json.loads(s3_get_sheet_response["Body"].read().decode()) @@ -128,7 +112,7 @@ def put(event, context): s3_client.put_object( ACL='private', Body = (bytes(json.dumps(new_sheet_data).encode('UTF-8'))), - Bucket = cheetsheet_bucket_name, + Bucket = SHEET_DATA_S3_BUCKET, Key=f'{user}/{event["pathParameters"]["sheetName"]}/sheet.json' ) @@ -141,30 +125,3 @@ def put(event, context): } }) } - -def main(event, context): - print('TEST') - if event["httpMethod"] == "GET": - response = get(event, context) - elif event["httpMethod"] == "PUT": - response = put(event, context) - elif event["httpMethod"] == "DELETE": - response = delete(event, context) - else: - return { - "statusCode": 405, - "body": json.dumps({ - "message": "Method Not Allowed" - }) - } - response["headers"] = {'Access-Control-Allow-Origin': "*"} - return response - -# Helper Methods -def get_error_response(message, statusCode=400): - return { - 'statusCode': statusCode, - 'body': json.dumps({ - 'message': message - }) - } diff --git a/api/standup-api.sh b/api/standup-api.sh index 8daac24..02b646d 100644 --- a/api/standup-api.sh +++ b/api/standup-api.sh @@ -1,2 +1,5 @@ # Starts the API with SAM LOCAL +# sam build --use-container +# sam local start-api --host 0.0.0.0 -p 3000 -v $SAM_LOCAL_ABSOLUTE_PATH +pip install -r ./requirements.txt -t src/__dependencies__ sam local start-api --skip-pull-image --host 0.0.0.0 -p 3000 -v $SAM_LOCAL_ABSOLUTE_PATH diff --git a/api/template.yaml b/api/template.yaml index b18a58b..bf41643 100644 --- a/api/template.yaml +++ b/api/template.yaml @@ -10,7 +10,7 @@ Globals: Function: Runtime: python3.7 Timeout: 3 - MemorySize: 256 + MemorySize: 512 Environment: Variables: CLIENT_UI_SUBDOMAIN: $CLIENT_UI_SUBDOMAIN @@ -24,42 +24,36 @@ Globals: AllowOrigin: "'*'" Resources: - #/sheet - SheetFunction: + + ApiFunction: Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction Properties: - CodeUri: sheet/_code_ + CodeUri: src Handler: app.main Events: - Get: + #/sheet + Get_sheet: Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api Properties: Path: /sheet Method: get - Post: + Post_sheet/{sheetName}: Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api Properties: Path: /sheet Method: post - - #/sheet/{sheetName} - SheetSheetNameFunction: - Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction - Properties: - CodeUri: sheet/{sheetName}/_code_ - Handler: app.main - Events: - Get: + #/sheet/{sheetName} + Get_sheet/{sheetName}: Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api Properties: Path: /sheet/{sheetName} Method: get - Delete: + Delete_sheet/{sheetName}: Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api Properties: Path: /sheet/{sheetName} Method: delete - Put: + Put_sheet/{sheetName}: Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api Properties: Path: /sheet/{sheetName} diff --git a/docker-compose.yml b/docker-compose.yml index f36d083..40f31e5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,4 +27,4 @@ services: - ./api:${SAM_LOCAL_ABSOLUTE_PATH} ports: - "3000:3000" - command: sh standup-api.sh + command: bash standup-api.sh