Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate local server to FastAPI #1577

Merged
merged 4 commits into from
Sep 26, 2024
Merged

migrate local server to FastAPI #1577

merged 4 commits into from
Sep 26, 2024

Conversation

petrkalos
Copy link
Contributor

@petrkalos petrkalos commented Sep 25, 2024

Feature or Bugfix

  • Refactoring

Detail

  • Migrate local server Flask to FastAPI
  • Upgrade and align versions of important libraries (aws-cdk-lib/boto3)
  • Simplify requirements files (removed explicitly defined deps that were not required or were implicitly pulled by other packages).

Testing

Penting succesful run on dev pipeline

Security

Please answer the questions below briefly where applicable, or write N/A. Based on
OWASP 10.

  • Does this PR introduce or modify any input fields or queries - this includes
    fetching data from storage outside the application (e.g. a database, an S3 bucket)?
    • Is the input sanitized?
    • What precautions are you taking before deserializing the data you consume?
    • Is injection prevented by parametrizing queries?
    • Have you ensured no eval or similar functions are used?
  • Does this PR introduce any functionality or component that requires authorization?
    • How have you ensured it respects the existing AuthN/AuthZ mechanisms?
    • Are you logging failed auth attempts?
  • Are you using or adding any cryptographic features?
    • Do you use a standard proven implementations?
    • Are the used keys controlled by the customer? Where are they stored?
  • Are you introducing any new policies/roles/users?
    • Have you used the least-privilege principle? How?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@petrkalos petrkalos marked this pull request as ready for review September 25, 2024 19:00
tests/client.py Show resolved Hide resolved
# GraphQL queries are always sent as POST
# Note: Passing the request to the context is optional.
# In Flask, the current request is always accessible as flask.request
data = request.get_json()
data = await request.json()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why is this request async? I might be getting it wrong, but is it just waiting for the request data? Because the graphql_sync call is synchronous no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.json() is declared as async thus to get the results we must await it, otherwise we get back a promise. Thus if you have to call await you must declare the calling method as async.

{
'id': 'AwsSolutions-SMG4',
'reason': 'Database is used for test purposes',
},
]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we get this exception in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think because I upgraded the aws-cdk-lib

Copy link
Contributor

@dlpzx dlpzx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Tested locally!

@petrkalos petrkalos merged commit ab7e2a9 into main Sep 26, 2024
10 checks passed
@petrkalos petrkalos deleted the feature/drop_flask branch September 26, 2024 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants