From 7694f736ec869f5391d70ac2dcfaaa11356de936 Mon Sep 17 00:00:00 2001 From: "Nikola R. Hristov" Date: Sun, 17 Mar 2024 16:43:56 +0200 Subject: [PATCH 01/43] squash! --- .devcontainer/devcontainer.json | 31 ------------------------ .github/dependabot.yml | 6 ----- .github/workflows/test-application.yml | 33 -------------------------- .vscode/launch.json | 19 --------------- 4 files changed, 89 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/test-application.yml delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index ee3d10a..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,6 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "pip" - directory: "/" # Location of package manifests - schedule: - interval: "weekly" diff --git a/.github/workflows/test-application.yml b/.github/workflows/test-application.yml deleted file mode 100644 index 0b99df1..0000000 --- a/.github/workflows/test-application.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Test Application - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - env: - PORT: 8000 - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Start the app - run: uvicorn main:app --host 0.0.0.0 --port ${{ env.PORT }} & - - - name: Sleep for 1 minute - run: sleep 60 - - - name: Stop the app - run: pkill -f 'uvicorn main:app' - diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From a6d14bfb113f26fe1f68f66b7a42300487cd71bd Mon Sep 17 00:00:00 2001 From: "Nikola R. Hristov" Date: Wed, 1 May 2024 02:46:35 +0300 Subject: [PATCH 02/43] squash! --- .devcontainer/devcontainer.json | 31 ------------------------ .github/dependabot.yml | 6 ----- .github/workflows/test-application.yml | 33 -------------------------- .vscode/launch.json | 19 --------------- 4 files changed, 89 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/test-application.yml delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index ee3d10a..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,6 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "pip" - directory: "/" # Location of package manifests - schedule: - interval: "weekly" diff --git a/.github/workflows/test-application.yml b/.github/workflows/test-application.yml deleted file mode 100644 index 0b99df1..0000000 --- a/.github/workflows/test-application.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Test Application - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - env: - PORT: 8000 - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Start the app - run: uvicorn main:app --host 0.0.0.0 --port ${{ env.PORT }} & - - - name: Sleep for 1 minute - run: sleep 60 - - - name: Stop the app - run: pkill -f 'uvicorn main:app' - diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From 6d713e599a3bbee2329a20460bcf7eeecf896897 Mon Sep 17 00:00:00 2001 From: "Nikola R. Hristov" Date: Wed, 1 May 2024 05:13:55 +0300 Subject: [PATCH 03/43] squash! --- .github/dependabot.yml | 14 ++++++++ .github/workflows/Dependabot.yml | 45 +++++++++++++++++++++++++ .github/workflows/GitHub.yml | 57 ++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/Dependabot.yml create mode 100644 .github/workflows/GitHub.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4242a05 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +enable-beta-ecosystems: true + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" + versioning-strategy: increase diff --git a/.github/workflows/Dependabot.yml b/.github/workflows/Dependabot.yml new file mode 100644 index 0000000..e6091e5 --- /dev/null +++ b/.github/workflows/Dependabot.yml @@ -0,0 +1,45 @@ +name: Dependabot + +concurrency: + group: Dependabot-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + security-events: write + contents: write + pull-requests: write + +on: + workflow_dispatch: + pull_request: + +jobs: + Approve: + runs-on: ubuntu-latest + + if: ${{ github.actor == 'dependabot[bot]' }} + + steps: + - uses: dependabot/fetch-metadata@v2.1.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + Merge: + runs-on: ubuntu-latest + + if: ${{ github.actor == 'dependabot[bot]' }} + + steps: + - uses: dependabot/fetch-metadata@v2.1.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/GitHub.yml b/.github/workflows/GitHub.yml new file mode 100644 index 0000000..0be30ba --- /dev/null +++ b/.github/workflows/GitHub.yml @@ -0,0 +1,57 @@ +name: GitHub + +concurrency: + group: GitHub-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + issues: write + pull-requests: write + +on: + issues: + types: [opened] + pull_request: + types: [opened] + +jobs: + Assign: + runs-on: ubuntu-latest + + env: + ADBLOCK: true + ASTRO_TELEMETRY_DISABLED: 1 + AUTOMATEDLAB_TELEMETRY_OPTOUT: 1 + AZURE_CORE_COLLECT_TELEMETRY: 0 + CHOOSENIM_NO_ANALYTICS: 1 + DIEZ_DO_NOT_TRACK: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT: 1 + DO_NOT_TRACK: 1 + ET_NO_TELEMETRY: 1 + GATSBY_TELEMETRY_DISABLED: 1 + GATSBY_TELEMETRY_OPTOUT: 1 + GATSBY_TELEMETRY_OPT_OUT: 1 + GRIT_TELEMETRY_DISABLED: 1 + HASURA_GRAPHQL_ENABLE_TELEMETRY: false + HINT_TELEMETRY: off + HOMEBREW_NO_ANALYTICS: 1 + INFLUXD_REPORTING_DISABLED: true + ITERATIVE_DO_NOT_TRACK: 1 + NEXT_TELEMETRY_DEBUG: 1 + NEXT_TELEMETRY_DISABLED: 1 + NG_CLI_ANALYTICS: false + NUXT_TELEMETRY_DISABLED: 1 + PIN_DO_NOT_TRACK: 1 + POWERSHELL_TELEMETRY_OPTOUT: 1 + SAM_CLI_TELEMETRY: 0 + STNOUPGRADE: 1 + STRIPE_CLI_TELEMETRY_OPTOUT: 1 + TELEMETRY_DISABLED: 1 + + steps: + - uses: pozil/auto-assign-issue@v1.14.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + assignees: NikolaRHristov + numOfAssignee: 1 From 9c0ff1e69d9cb2f276e9946db4d391d73bed5aec Mon Sep 17 00:00:00 2001 From: "Nikola R. Hristov" Date: Wed, 1 May 2024 22:53:19 +0300 Subject: [PATCH 04/43] squash! --- .github/dependabot.yml | 14 -------- .github/workflows/Dependabot.yml | 45 ------------------------- .github/workflows/GitHub.yml | 57 -------------------------------- 3 files changed, 116 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/Dependabot.yml delete mode 100644 .github/workflows/GitHub.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 4242a05..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: 2 -enable-beta-ecosystems: true - -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" - - - package-ecosystem: "pip" - directory: "/" - schedule: - interval: "daily" - versioning-strategy: increase diff --git a/.github/workflows/Dependabot.yml b/.github/workflows/Dependabot.yml deleted file mode 100644 index e6091e5..0000000 --- a/.github/workflows/Dependabot.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Dependabot - -concurrency: - group: Dependabot-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - security-events: write - contents: write - pull-requests: write - -on: - workflow_dispatch: - pull_request: - -jobs: - Approve: - runs-on: ubuntu-latest - - if: ${{ github.actor == 'dependabot[bot]' }} - - steps: - - uses: dependabot/fetch-metadata@v2.1.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - run: gh pr review --approve "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - Merge: - runs-on: ubuntu-latest - - if: ${{ github.actor == 'dependabot[bot]' }} - - steps: - - uses: dependabot/fetch-metadata@v2.1.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - run: gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/GitHub.yml b/.github/workflows/GitHub.yml deleted file mode 100644 index 0be30ba..0000000 --- a/.github/workflows/GitHub.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: GitHub - -concurrency: - group: GitHub-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - issues: write - pull-requests: write - -on: - issues: - types: [opened] - pull_request: - types: [opened] - -jobs: - Assign: - runs-on: ubuntu-latest - - env: - ADBLOCK: true - ASTRO_TELEMETRY_DISABLED: 1 - AUTOMATEDLAB_TELEMETRY_OPTOUT: 1 - AZURE_CORE_COLLECT_TELEMETRY: 0 - CHOOSENIM_NO_ANALYTICS: 1 - DIEZ_DO_NOT_TRACK: 1 - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT: 1 - DO_NOT_TRACK: 1 - ET_NO_TELEMETRY: 1 - GATSBY_TELEMETRY_DISABLED: 1 - GATSBY_TELEMETRY_OPTOUT: 1 - GATSBY_TELEMETRY_OPT_OUT: 1 - GRIT_TELEMETRY_DISABLED: 1 - HASURA_GRAPHQL_ENABLE_TELEMETRY: false - HINT_TELEMETRY: off - HOMEBREW_NO_ANALYTICS: 1 - INFLUXD_REPORTING_DISABLED: true - ITERATIVE_DO_NOT_TRACK: 1 - NEXT_TELEMETRY_DEBUG: 1 - NEXT_TELEMETRY_DISABLED: 1 - NG_CLI_ANALYTICS: false - NUXT_TELEMETRY_DISABLED: 1 - PIN_DO_NOT_TRACK: 1 - POWERSHELL_TELEMETRY_OPTOUT: 1 - SAM_CLI_TELEMETRY: 0 - STNOUPGRADE: 1 - STRIPE_CLI_TELEMETRY_OPTOUT: 1 - TELEMETRY_DISABLED: 1 - - steps: - - uses: pozil/auto-assign-issue@v1.14.0 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - assignees: NikolaRHristov - numOfAssignee: 1 From 2bbee7d436298d402cbfe3a84e7a69eefce07738 Mon Sep 17 00:00:00 2001 From: "Nikola R. Hristov" Date: Thu, 2 May 2024 04:23:11 +0300 Subject: [PATCH 05/43] squash! --- .github/dependabot.yml | 14 ++++++++ .github/workflows/Dependabot.yml | 45 +++++++++++++++++++++++++ .github/workflows/GitHub.yml | 57 ++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/Dependabot.yml create mode 100644 .github/workflows/GitHub.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4242a05 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +enable-beta-ecosystems: true + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" + versioning-strategy: increase diff --git a/.github/workflows/Dependabot.yml b/.github/workflows/Dependabot.yml new file mode 100644 index 0000000..e6091e5 --- /dev/null +++ b/.github/workflows/Dependabot.yml @@ -0,0 +1,45 @@ +name: Dependabot + +concurrency: + group: Dependabot-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + security-events: write + contents: write + pull-requests: write + +on: + workflow_dispatch: + pull_request: + +jobs: + Approve: + runs-on: ubuntu-latest + + if: ${{ github.actor == 'dependabot[bot]' }} + + steps: + - uses: dependabot/fetch-metadata@v2.1.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + Merge: + runs-on: ubuntu-latest + + if: ${{ github.actor == 'dependabot[bot]' }} + + steps: + - uses: dependabot/fetch-metadata@v2.1.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/GitHub.yml b/.github/workflows/GitHub.yml new file mode 100644 index 0000000..0be30ba --- /dev/null +++ b/.github/workflows/GitHub.yml @@ -0,0 +1,57 @@ +name: GitHub + +concurrency: + group: GitHub-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + issues: write + pull-requests: write + +on: + issues: + types: [opened] + pull_request: + types: [opened] + +jobs: + Assign: + runs-on: ubuntu-latest + + env: + ADBLOCK: true + ASTRO_TELEMETRY_DISABLED: 1 + AUTOMATEDLAB_TELEMETRY_OPTOUT: 1 + AZURE_CORE_COLLECT_TELEMETRY: 0 + CHOOSENIM_NO_ANALYTICS: 1 + DIEZ_DO_NOT_TRACK: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT: 1 + DO_NOT_TRACK: 1 + ET_NO_TELEMETRY: 1 + GATSBY_TELEMETRY_DISABLED: 1 + GATSBY_TELEMETRY_OPTOUT: 1 + GATSBY_TELEMETRY_OPT_OUT: 1 + GRIT_TELEMETRY_DISABLED: 1 + HASURA_GRAPHQL_ENABLE_TELEMETRY: false + HINT_TELEMETRY: off + HOMEBREW_NO_ANALYTICS: 1 + INFLUXD_REPORTING_DISABLED: true + ITERATIVE_DO_NOT_TRACK: 1 + NEXT_TELEMETRY_DEBUG: 1 + NEXT_TELEMETRY_DISABLED: 1 + NG_CLI_ANALYTICS: false + NUXT_TELEMETRY_DISABLED: 1 + PIN_DO_NOT_TRACK: 1 + POWERSHELL_TELEMETRY_OPTOUT: 1 + SAM_CLI_TELEMETRY: 0 + STNOUPGRADE: 1 + STRIPE_CLI_TELEMETRY_OPTOUT: 1 + TELEMETRY_DISABLED: 1 + + steps: + - uses: pozil/auto-assign-issue@v1.14.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + assignees: NikolaRHristov + numOfAssignee: 1 From cca69ea755dbb87fb09b90976e941edbc625209f Mon Sep 17 00:00:00 2001 From: "Nikola R. Hristov" Date: Thu, 2 May 2024 23:32:04 +0300 Subject: [PATCH 06/43] squash! --- .gitignore | 106 -------------------------------------- CODE_OF_CONDUCT.md | 9 ---- LICENSE | 21 -------- README.md | 48 ----------------- SECURITY.md | 41 --------------- SUPPORT.md | 25 --------- flushdb.py | 9 ---- main.py | 126 --------------------------------------------- models.py | 9 ---- requirements.txt | 18 ------- 10 files changed, 412 deletions(-) delete mode 100644 .gitignore delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 LICENSE delete mode 100644 README.md delete mode 100644 SECURITY.md delete mode 100644 SUPPORT.md delete mode 100644 flushdb.py delete mode 100644 main.py delete mode 100644 models.py delete mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore deleted file mode 100644 index f75400b..0000000 --- a/.gitignore +++ /dev/null @@ -1,106 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ - -settings.json \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index f9ba8cf..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,9 +0,0 @@ -# Microsoft Open Source Code of Conduct - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). - -Resources: - -- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) -- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) -- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 62f454e..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md deleted file mode 100644 index 7c991dd..0000000 --- a/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# Python/FastAPI Tutorial for Visual Studio Code -This sample contains the completed program from the tutorial: [FastAPI in Visual Studio Code](https://code.visualstudio.com/docs/python/tutorial-fastapi). Immediate steps are not included. - -## Run the app using GitHub Codespaces -[GitHub Codespaces](https://github.com/features/codespaces) provides cloud-powered development environments that work how and where you want it to. To learn how to set up a GitHub Codespace for this repository, check the [documentation](https://docs.github.com/en/codespaces/developing-in-codespaces/creating-a-codespace-for-a-repository#creating-a-codespace-for-a-repository). - -Once you open this repository in GitHub Codespaces, you can press **F5** to start the debugger and run the application. - -Once it's ready, you will see a notification with a button `Open in the Browser`. Clicking the button will open your application on the browser. You can then add `/docs` to the end of the URL to access the Swagger UI and interact with the application! - -## Run the app locally in VS Code - -There are diffent ways you can run this app locally in VS Code depending on your operating system. To get started, first clone this project on your machine and then open it in VS Code (**File** > **Open Folder...**). - -### Windows -To run this app locally in VS Code on Windows, you can use either [WSL](https://learn.microsoft.com/en-us/windows/wsl/) (Windows Subsystem for Linux) or [Docker](https://www.docker.com/products/docker-desktop). - -#### Docker Containers -1. Make sure you have [Docker installed](https://www.docker.com/products/docker-desktop) -1. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) -1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and run the "Dev Container: Reopen in Container" command. -1. Press **F5** to debug your application! - -#### WSL -1. Make sure you have [WSL installed](https://learn.microsoft.com/en-us/windows/wsl/) -1. Install the [WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) for VS Code -1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and run the "WSL: Reopen Folder in WSL" command -1. Follow the remaining steps for [macOS/Linux](#macos--linux) below. - -### macOS / Linux - -1. Install the [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) for VS Code -1. Run the "Python: Create Environment" command in the Command Palette -1. Select `Venv`, the latest available version of Python and then the `requirements.txt` file to install the dependencies. -1. Press **F5** to run your application! - -## Contributing -Contributions to the sample are welcome! When submitting changes, also consider submitting matching changes to the tutorial, the source file for which is [tutorial-fastapi.md](https://github.com/Microsoft/vscode-docs/blob/master/docs/python/tutorial-fastapi.md). - -Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. - -When you submit a pull request, a CLA-bot automatically determines whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. - -## Additional details - -* This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -* For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or -* Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index b3c89ef..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,41 +0,0 @@ - - -## Security - -Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin). - -If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below. - -## Reporting Security Issues - -**Please do not report security vulnerabilities through public GitHub issues.** - -Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report). - -If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp). - -You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). - -Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: - - * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) - * Full paths of source file(s) related to the manifestation of the issue - * The location of the affected source code (tag/branch/commit or direct URL) - * Any special configuration required to reproduce the issue - * Step-by-step instructions to reproduce the issue - * Proof-of-concept or exploit code (if possible) - * Impact of the issue, including how an attacker might exploit the issue - -This information will help us triage your report more quickly. - -If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs. - -## Preferred Languages - -We prefer all communications to be in English. - -## Policy - -Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd). - - diff --git a/SUPPORT.md b/SUPPORT.md deleted file mode 100644 index 291d4d4..0000000 --- a/SUPPORT.md +++ /dev/null @@ -1,25 +0,0 @@ -# TODO: The maintainer of this repo has not yet edited this file - -**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? - -- **No CSS support:** Fill out this template with information about how to file issues and get help. -- **Yes CSS support:** Fill out an intake form at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work with/help you to determine next steps. -- **Not sure?** Fill out an intake as though the answer were "Yes". CSS will help you decide. - -*Then remove this first heading from this SUPPORT.MD file before publishing your repo.* - -# Support - -## How to file issues and get help - -This project uses GitHub Issues to track bugs and feature requests. Please search the existing -issues before filing new issues to avoid duplicates. For new issues, file your bug or -feature request as a new Issue. - -For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE -FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER -CHANNEL. WHERE WILL YOU HELP PEOPLE?**. - -## Microsoft Support Policy - -Support for this **PROJECT or PRODUCT** is limited to the resources listed above. diff --git a/flushdb.py b/flushdb.py deleted file mode 100644 index 65442ad..0000000 --- a/flushdb.py +++ /dev/null @@ -1,9 +0,0 @@ -""" -This module is used to interact with a Redis database. - -WARNING: This script will flush the entire Redis database. Use with caution. -""" -import redis - -redis_client = redis.StrictRedis(host="0.0.0.0", port=6379, db=0, decode_responses=True) -redis_client.flushdb() diff --git a/main.py b/main.py deleted file mode 100644 index 1ad8072..0000000 --- a/main.py +++ /dev/null @@ -1,126 +0,0 @@ -import os - -import redis -from fastapi import FastAPI, HTTPException, Request - -from models import ItemPayload - -app = FastAPI() - -redis_client = redis.StrictRedis(host="0.0.0.0", port=6379, db=0, decode_responses=True) - - -@app.get("/") -def home(request: Request) -> dict[str, str]: - url: str = ( - f"https://{os.getenv('CODESPACE_NAME')}-8000.{os.getenv('GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN')}/" - if os.getenv("CODESPACE_NAME") - else str(request.base_url) - ) - return { - "message": f"Navigate to the following URL to access the Swagger UI: {url}docs" - } - - -# Route to add an item -@app.post("/items/{item_name}/{quantity}") -def add_item(item_name: str, quantity: int) -> dict[str, ItemPayload]: - if quantity <= 0: - raise HTTPException(status_code=400, detail="Quantity must be greater than 0.") - - # Check if item already exists - item_id_str: str | None = redis_client.hget("item_name_to_id", item_name) - - if item_id_str is not None: - item_id = int(item_id_str) - quantity = redis_client.hincrby(f"item_id:{item_id}", "quantity", quantity) - else: - # Generate an id for the item - item_id: int = redis_client.incr("item_ids") - redis_client.hset( - f"item_id:{item_id}", - mapping={ - "item_id": item_id, - "item_name": item_name, - "quantity": quantity, - }, - ) - # Create a set so we can search by name too - redis_client.hset("item_name_to_id", item_name, item_id) - - return { - "item": ItemPayload(item_id=item_id, item_name=item_name, quantity=quantity) - } - - -# Route to list a specific item by id but using Redis -@app.get("/items/{item_id}") -def list_item(item_id: int) -> dict[str, dict[str, str]]: - if not redis_client.hexists(f"item_id:{item_id}", "item_id"): - raise HTTPException(status_code=404, detail="Item not found.") - else: - return {"item": redis_client.hgetall(f"item_id:{item_id}")} - - -@app.get("/items") -def list_items() -> dict[str, list[ItemPayload]]: - items: list[ItemPayload] = [] - stored_items: dict[str, str] = redis_client.hgetall("item_name_to_id") - - for name, id_str in stored_items.items(): - item_id: int = int(id_str) - - item_name_str: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") - if item_name_str is not None: - item_name: str = item_name_str - else: - continue # skip this item if it has no name - - item_quantity_str: str | None = redis_client.hget( - f"item_id:{item_id}", "quantity" - ) - if item_quantity_str is not None: - item_quantity: int = int(item_quantity_str) - else: - item_quantity = 0 - - items.append( - ItemPayload(item_id=item_id, item_name=item_name, quantity=item_quantity) - ) - - return {"items": items} - - -# Route to delete a specific item by id but using Redis -@app.delete("/items/{item_id}") -def delete_item(item_id: int) -> dict[str, str]: - if not redis_client.hexists(f"item_id:{item_id}", "item_id"): - raise HTTPException(status_code=404, detail="Item not found.") - else: - item_name: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") - redis_client.hdel("item_name_to_id", f"{item_name}") - redis_client.delete(f"item_id:{item_id}") - return {"result": "Item deleted."} - - -# Route to remove some quantity of a specific item by id but using Redis -@app.delete("/items/{item_id}/{quantity}") -def remove_quantity(item_id: int, quantity: int) -> dict[str, str]: - if not redis_client.hexists(f"item_id:{item_id}", "item_id"): - raise HTTPException(status_code=404, detail="Item not found.") - - item_quantity: str | None = redis_client.hget(f"item_id:{item_id}", "quantity") - - # if quantity to be removed is higher or equal to item's quantity, delete the item - if item_quantity is None: - existing_quantity: int = 0 - else: - existing_quantity: int = int(item_quantity) - if existing_quantity <= quantity: - item_name: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") - redis_client.hdel("item_name_to_id", f"{item_name}") - redis_client.delete(f"item_id:{item_id}") - return {"result": "Item deleted."} - else: - redis_client.hincrby(f"item_id:{item_id}", "quantity", -quantity) - return {"result": f"{quantity} items removed."} diff --git a/models.py b/models.py deleted file mode 100644 index bba7954..0000000 --- a/models.py +++ /dev/null @@ -1,9 +0,0 @@ -from typing import Optional - -from pydantic import BaseModel - - -class ItemPayload(BaseModel): - item_id: Optional[int] - item_name: str - quantity: int diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 6ea752e..0000000 --- a/requirements.txt +++ /dev/null @@ -1,18 +0,0 @@ -annotated-types==0.6.0 -anyio==3.7.1 -cffi==1.16.0 -click==8.1.7 -cryptography==41.0.4 -fastapi==0.104.0 -h11==0.14.0 -idna==3.4 -pycparser==2.21 -pydantic==2.4.2 -pydantic-core==2.10.1 -redis==5.0.1 -sniffio==1.3.0 -starlette==0.27.0 -types-pyopenssl==23.3.0.0 -types-redis==4.6.0.7 -typing-extensions==4.8.0 -uvicorn==0.23.2 From 97dc6a9eeecdcb95241a368eb8c2ce284ddcd8b7 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Wed, 15 May 2024 05:19:08 +0300 Subject: [PATCH 07/43] squash! --- .github/workflows/GitHub.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/GitHub.yml b/.github/workflows/GitHub.yml index 0be30ba..5e814e3 100644 --- a/.github/workflows/GitHub.yml +++ b/.github/workflows/GitHub.yml @@ -50,7 +50,7 @@ jobs: TELEMETRY_DISABLED: 1 steps: - - uses: pozil/auto-assign-issue@v1.14.0 + - uses: pozil/auto-assign-issue@v2.0.0 with: repo-token: ${{ secrets.GITHUB_TOKEN }} assignees: NikolaRHristov From e17a5a57d909c07867e1070c5d656a7968e42d52 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Fri, 17 May 2024 08:12:23 +0300 Subject: [PATCH 08/43] squash! --- .github/dependabot.yml | 14 -------- .github/workflows/Dependabot.yml | 45 ------------------------- .github/workflows/GitHub.yml | 57 -------------------------------- 3 files changed, 116 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/Dependabot.yml delete mode 100644 .github/workflows/GitHub.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 4242a05..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: 2 -enable-beta-ecosystems: true - -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" - - - package-ecosystem: "pip" - directory: "/" - schedule: - interval: "daily" - versioning-strategy: increase diff --git a/.github/workflows/Dependabot.yml b/.github/workflows/Dependabot.yml deleted file mode 100644 index e6091e5..0000000 --- a/.github/workflows/Dependabot.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Dependabot - -concurrency: - group: Dependabot-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - security-events: write - contents: write - pull-requests: write - -on: - workflow_dispatch: - pull_request: - -jobs: - Approve: - runs-on: ubuntu-latest - - if: ${{ github.actor == 'dependabot[bot]' }} - - steps: - - uses: dependabot/fetch-metadata@v2.1.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - run: gh pr review --approve "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - Merge: - runs-on: ubuntu-latest - - if: ${{ github.actor == 'dependabot[bot]' }} - - steps: - - uses: dependabot/fetch-metadata@v2.1.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - run: gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/GitHub.yml b/.github/workflows/GitHub.yml deleted file mode 100644 index 5e814e3..0000000 --- a/.github/workflows/GitHub.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: GitHub - -concurrency: - group: GitHub-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - issues: write - pull-requests: write - -on: - issues: - types: [opened] - pull_request: - types: [opened] - -jobs: - Assign: - runs-on: ubuntu-latest - - env: - ADBLOCK: true - ASTRO_TELEMETRY_DISABLED: 1 - AUTOMATEDLAB_TELEMETRY_OPTOUT: 1 - AZURE_CORE_COLLECT_TELEMETRY: 0 - CHOOSENIM_NO_ANALYTICS: 1 - DIEZ_DO_NOT_TRACK: 1 - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT: 1 - DO_NOT_TRACK: 1 - ET_NO_TELEMETRY: 1 - GATSBY_TELEMETRY_DISABLED: 1 - GATSBY_TELEMETRY_OPTOUT: 1 - GATSBY_TELEMETRY_OPT_OUT: 1 - GRIT_TELEMETRY_DISABLED: 1 - HASURA_GRAPHQL_ENABLE_TELEMETRY: false - HINT_TELEMETRY: off - HOMEBREW_NO_ANALYTICS: 1 - INFLUXD_REPORTING_DISABLED: true - ITERATIVE_DO_NOT_TRACK: 1 - NEXT_TELEMETRY_DEBUG: 1 - NEXT_TELEMETRY_DISABLED: 1 - NG_CLI_ANALYTICS: false - NUXT_TELEMETRY_DISABLED: 1 - PIN_DO_NOT_TRACK: 1 - POWERSHELL_TELEMETRY_OPTOUT: 1 - SAM_CLI_TELEMETRY: 0 - STNOUPGRADE: 1 - STRIPE_CLI_TELEMETRY_OPTOUT: 1 - TELEMETRY_DISABLED: 1 - - steps: - - uses: pozil/auto-assign-issue@v2.0.0 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - assignees: NikolaRHristov - numOfAssignee: 1 From eab6fdc1d3e2f1eb3b8852c8cea5c625c220556b Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Mon, 20 May 2024 15:28:11 +0300 Subject: [PATCH 09/43] squash! --- .devcontainer/devcontainer.json | 31 ------------------------ .github/dependabot.yml | 6 ----- .github/workflows/test-application.yml | 33 -------------------------- .vscode/launch.json | 19 --------------- 4 files changed, 89 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/test-application.yml delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index ee3d10a..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,6 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "pip" - directory: "/" # Location of package manifests - schedule: - interval: "weekly" diff --git a/.github/workflows/test-application.yml b/.github/workflows/test-application.yml deleted file mode 100644 index 0b99df1..0000000 --- a/.github/workflows/test-application.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Test Application - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - env: - PORT: 8000 - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Start the app - run: uvicorn main:app --host 0.0.0.0 --port ${{ env.PORT }} & - - - name: Sleep for 1 minute - run: sleep 60 - - - name: Stop the app - run: pkill -f 'uvicorn main:app' - diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From 123c37815e77e6b9892f418c730041b25619248d Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Thu, 23 May 2024 11:52:26 +0300 Subject: [PATCH 10/43] squash! --- .gitignore | 210 ++++++++++++++++++++++++++--------------------------- 1 file changed, 105 insertions(+), 105 deletions(-) diff --git a/.gitignore b/.gitignore index f75400b..c3caf9a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,106 +1,106 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ - +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + settings.json \ No newline at end of file From 1d290482bc4cf18d08e7072b8b7cb6566adc70db Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Thu, 23 May 2024 12:55:27 +0300 Subject: [PATCH 11/43] squash! --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index c3caf9a..bc1d61f 100644 --- a/.gitignore +++ b/.gitignore @@ -82,10 +82,8 @@ celerybeat-schedule *.sage.py # Environments -.env .venv env/ -venv/ ENV/ env.bak/ venv.bak/ From 756b00427a48e5cc1315001b55ca97b2eae5afb5 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sat, 25 May 2024 01:17:02 +0300 Subject: [PATCH 12/43] squash! --- .github/dependabot.yml | 14 ++++++++ .github/workflows/Dependabot.yml | 45 +++++++++++++++++++++++++ .github/workflows/GitHub.yml | 57 ++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/Dependabot.yml create mode 100644 .github/workflows/GitHub.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4242a05 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +enable-beta-ecosystems: true + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" + versioning-strategy: increase diff --git a/.github/workflows/Dependabot.yml b/.github/workflows/Dependabot.yml new file mode 100644 index 0000000..e6091e5 --- /dev/null +++ b/.github/workflows/Dependabot.yml @@ -0,0 +1,45 @@ +name: Dependabot + +concurrency: + group: Dependabot-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + security-events: write + contents: write + pull-requests: write + +on: + workflow_dispatch: + pull_request: + +jobs: + Approve: + runs-on: ubuntu-latest + + if: ${{ github.actor == 'dependabot[bot]' }} + + steps: + - uses: dependabot/fetch-metadata@v2.1.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + Merge: + runs-on: ubuntu-latest + + if: ${{ github.actor == 'dependabot[bot]' }} + + steps: + - uses: dependabot/fetch-metadata@v2.1.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/GitHub.yml b/.github/workflows/GitHub.yml new file mode 100644 index 0000000..5e814e3 --- /dev/null +++ b/.github/workflows/GitHub.yml @@ -0,0 +1,57 @@ +name: GitHub + +concurrency: + group: GitHub-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + issues: write + pull-requests: write + +on: + issues: + types: [opened] + pull_request: + types: [opened] + +jobs: + Assign: + runs-on: ubuntu-latest + + env: + ADBLOCK: true + ASTRO_TELEMETRY_DISABLED: 1 + AUTOMATEDLAB_TELEMETRY_OPTOUT: 1 + AZURE_CORE_COLLECT_TELEMETRY: 0 + CHOOSENIM_NO_ANALYTICS: 1 + DIEZ_DO_NOT_TRACK: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT: 1 + DO_NOT_TRACK: 1 + ET_NO_TELEMETRY: 1 + GATSBY_TELEMETRY_DISABLED: 1 + GATSBY_TELEMETRY_OPTOUT: 1 + GATSBY_TELEMETRY_OPT_OUT: 1 + GRIT_TELEMETRY_DISABLED: 1 + HASURA_GRAPHQL_ENABLE_TELEMETRY: false + HINT_TELEMETRY: off + HOMEBREW_NO_ANALYTICS: 1 + INFLUXD_REPORTING_DISABLED: true + ITERATIVE_DO_NOT_TRACK: 1 + NEXT_TELEMETRY_DEBUG: 1 + NEXT_TELEMETRY_DISABLED: 1 + NG_CLI_ANALYTICS: false + NUXT_TELEMETRY_DISABLED: 1 + PIN_DO_NOT_TRACK: 1 + POWERSHELL_TELEMETRY_OPTOUT: 1 + SAM_CLI_TELEMETRY: 0 + STNOUPGRADE: 1 + STRIPE_CLI_TELEMETRY_OPTOUT: 1 + TELEMETRY_DISABLED: 1 + + steps: + - uses: pozil/auto-assign-issue@v2.0.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + assignees: NikolaRHristov + numOfAssignee: 1 From 5f2c072ff825b6b249f982ac888b8f3146448d7f Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sun, 26 May 2024 14:19:38 +0300 Subject: [PATCH 13/43] squash! --- CODE_OF_CONDUCT.md | 10 +- FUNDING.yml | 1 + LICENSE | 42 ++++---- README.md | 136 +++++++++++++++--------- SECURITY.md | 51 ++++++--- SUPPORT.md | 57 +++++----- main.py | 252 ++++++++++++++++++++++----------------------- models.py | 18 ++-- requirements.txt | 36 +++---- 9 files changed, 337 insertions(+), 266 deletions(-) create mode 100644 FUNDING.yml diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index f9ba8cf..bb1fb9a 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,9 +1,11 @@ # Microsoft Open Source Code of Conduct -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). Resources: -- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) -- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) -- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns +- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) +- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with + questions or concerns diff --git a/FUNDING.yml b/FUNDING.yml new file mode 100644 index 0000000..12f5195 --- /dev/null +++ b/FUNDING.yml @@ -0,0 +1 @@ +open_collective: code-editor-land diff --git a/LICENSE b/LICENSE index 62f454e..115963d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -MIT License - -Copyright (c) 2023 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +MIT License + +Copyright (c) 2023 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 7c991dd..4fdcd81 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,88 @@ -# Python/FastAPI Tutorial for Visual Studio Code -This sample contains the completed program from the tutorial: [FastAPI in Visual Studio Code](https://code.visualstudio.com/docs/python/tutorial-fastapi). Immediate steps are not included. - -## Run the app using GitHub Codespaces -[GitHub Codespaces](https://github.com/features/codespaces) provides cloud-powered development environments that work how and where you want it to. To learn how to set up a GitHub Codespace for this repository, check the [documentation](https://docs.github.com/en/codespaces/developing-in-codespaces/creating-a-codespace-for-a-repository#creating-a-codespace-for-a-repository). - -Once you open this repository in GitHub Codespaces, you can press **F5** to start the debugger and run the application. - -Once it's ready, you will see a notification with a button `Open in the Browser`. Clicking the button will open your application on the browser. You can then add `/docs` to the end of the URL to access the Swagger UI and interact with the application! - -## Run the app locally in VS Code - -There are diffent ways you can run this app locally in VS Code depending on your operating system. To get started, first clone this project on your machine and then open it in VS Code (**File** > **Open Folder...**). - -### Windows -To run this app locally in VS Code on Windows, you can use either [WSL](https://learn.microsoft.com/en-us/windows/wsl/) (Windows Subsystem for Linux) or [Docker](https://www.docker.com/products/docker-desktop). - -#### Docker Containers -1. Make sure you have [Docker installed](https://www.docker.com/products/docker-desktop) -1. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) -1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and run the "Dev Container: Reopen in Container" command. -1. Press **F5** to debug your application! - -#### WSL -1. Make sure you have [WSL installed](https://learn.microsoft.com/en-us/windows/wsl/) -1. Install the [WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) for VS Code -1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and run the "WSL: Reopen Folder in WSL" command -1. Follow the remaining steps for [macOS/Linux](#macos--linux) below. - -### macOS / Linux - -1. Install the [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) for VS Code -1. Run the "Python: Create Environment" command in the Command Palette -1. Select `Venv`, the latest available version of Python and then the `requirements.txt` file to install the dependencies. -1. Press **F5** to run your application! - -## Contributing -Contributions to the sample are welcome! When submitting changes, also consider submitting matching changes to the tutorial, the source file for which is [tutorial-fastapi.md](https://github.com/Microsoft/vscode-docs/blob/master/docs/python/tutorial-fastapi.md). - -Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. - -When you submit a pull request, a CLA-bot automatically determines whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. - -## Additional details - -* This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -* For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or -* Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. +# Python/FastAPI Tutorial for Visual Studio Code + +This sample contains the completed program from the tutorial: +[FastAPI in Visual Studio Code](https://code.visualstudio.com/docs/python/tutorial-fastapi). +Immediate steps are not included. + +## Run the app using GitHub Codespaces + +[GitHub Codespaces](https://github.com/features/codespaces) provides +cloud-powered development environments that work how and where you want it to. +To learn how to set up a GitHub Codespace for this repository, check the +[documentation](https://docs.github.com/en/codespaces/developing-in-codespaces/creating-a-codespace-for-a-repository#creating-a-codespace-for-a-repository). + +Once you open this repository in GitHub Codespaces, you can press **F5** to +start the debugger and run the application. + +Once it's ready, you will see a notification with a button +`Open in the Browser`. Clicking the button will open your application on the +browser. You can then add `/docs` to the end of the URL to access the Swagger UI +and interact with the application! + +## Run the app locally in VS Code + +There are diffent ways you can run this app locally in VS Code depending on your +operating system. To get started, first clone this project on your machine and +then open it in VS Code (**File** > **Open Folder...**). + +### Windows + +To run this app locally in VS Code on Windows, you can use either +[WSL](https://learn.microsoft.com/en-us/windows/wsl/) (Windows Subsystem for +Linux) or [Docker](https://www.docker.com/products/docker-desktop). + +#### Docker Containers + +1. Make sure you have + [Docker installed](https://www.docker.com/products/docker-desktop) +1. Install the + [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) +1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and + run the "Dev Container: Reopen in Container" command. +1. Press **F5** to debug your application! + +#### WSL + +1. Make sure you have + [WSL installed](https://learn.microsoft.com/en-us/windows/wsl/) +1. Install the + [WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) + for VS Code +1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and + run the "WSL: Reopen Folder in WSL" command +1. Follow the remaining steps for [macOS/Linux](#macos--linux) below. + +### macOS / Linux + +1. Install the + [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) + for VS Code +1. Run the "Python: Create Environment" command in the Command Palette +1. Select `Venv`, the latest available version of Python and then the + `requirements.txt` file to install the dependencies. +1. Press **F5** to run your application! + +## Contributing + +Contributions to the sample are welcome! When submitting changes, also consider +submitting matching changes to the tutorial, the source file for which is +[tutorial-fastapi.md](https://github.com/Microsoft/vscode-docs/blob/master/docs/python/tutorial-fastapi.md). + +Most contributions require you to agree to a Contributor License Agreement (CLA) +declaring that you have the right to, and actually do, grant us the rights to +use your contribution. For details, visit https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot automatically determines whether you +need to provide a CLA and decorate the PR appropriately (e.g., label, comment). +Simply follow the instructions provided by the bot. You will only need to do +this once across all repos using our CLA. + +## Additional details + +- This project has adopted the + [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +- For more information see the + [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) + or +- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any + additional questions or comments. diff --git a/SECURITY.md b/SECURITY.md index b3c89ef..27d107b 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,33 +2,53 @@ ## Security -Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin). +Microsoft takes the security of our software products and services seriously, +which includes all source code repositories managed through our GitHub +organizations, which include [Microsoft](https://github.com/Microsoft), +[Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), +[AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin). -If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below. +If you believe you have found a security vulnerability in any Microsoft-owned +repository that meets +[Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), +please report it to us as described below. ## Reporting Security Issues **Please do not report security vulnerabilities through public GitHub issues.** -Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report). +Instead, please report them to the Microsoft Security Response Center (MSRC) at +[https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report). -If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp). +If you prefer to submit without logging in, send email to +[secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your +message with our PGP key; please download it from the +[Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp). -You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). +You should receive a response within 24 hours. If for some reason you do not, +please follow up via email to ensure we received your original message. +Additional information can be found at +[microsoft.com/msrc](https://www.microsoft.com/msrc). -Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: +Please include the requested information listed below (as much as you can +provide) to help us better understand the nature and scope of the possible +issue: - * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) - * Full paths of source file(s) related to the manifestation of the issue - * The location of the affected source code (tag/branch/commit or direct URL) - * Any special configuration required to reproduce the issue - * Step-by-step instructions to reproduce the issue - * Proof-of-concept or exploit code (if possible) - * Impact of the issue, including how an attacker might exploit the issue +- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, + etc.) +- Full paths of source file(s) related to the manifestation of the issue +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- Step-by-step instructions to reproduce the issue +- Proof-of-concept or exploit code (if possible) +- Impact of the issue, including how an attacker might exploit the issue This information will help us triage your report more quickly. -If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs. +If you are reporting for a bug bounty, more complete reports can contribute to a +higher bounty award. Please visit our +[Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for +more details about our active programs. ## Preferred Languages @@ -36,6 +56,7 @@ We prefer all communications to be in English. ## Policy -Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd). +Microsoft follows the principle of +[Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd). diff --git a/SUPPORT.md b/SUPPORT.md index 291d4d4..4b5b614 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -1,25 +1,32 @@ -# TODO: The maintainer of this repo has not yet edited this file - -**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? - -- **No CSS support:** Fill out this template with information about how to file issues and get help. -- **Yes CSS support:** Fill out an intake form at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work with/help you to determine next steps. -- **Not sure?** Fill out an intake as though the answer were "Yes". CSS will help you decide. - -*Then remove this first heading from this SUPPORT.MD file before publishing your repo.* - -# Support - -## How to file issues and get help - -This project uses GitHub Issues to track bugs and feature requests. Please search the existing -issues before filing new issues to avoid duplicates. For new issues, file your bug or -feature request as a new Issue. - -For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE -FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER -CHANNEL. WHERE WILL YOU HELP PEOPLE?**. - -## Microsoft Support Policy - -Support for this **PROJECT or PRODUCT** is limited to the resources listed above. +# TODO: The maintainer of this repo has not yet edited this file + +**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this +product/project? + +- **No CSS support:** Fill out this template with information about how to + file issues and get help. +- **Yes CSS support:** Fill out an intake form at + [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work + with/help you to determine next steps. +- **Not sure?** Fill out an intake as though the answer were "Yes". CSS will + help you decide. + +_Then remove this first heading from this SUPPORT.MD file before publishing your +repo._ + +# Support + +## How to file issues and get help + +This project uses GitHub Issues to track bugs and feature requests. Please +search the existing issues before filing new issues to avoid duplicates. For new +issues, file your bug or feature request as a new Issue. + +For help and questions about using this project, please **REPO MAINTAINER: +INSERT INSTRUCTIONS HERE FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. +COULD BE A STACK OVERFLOW TAG OR OTHER CHANNEL. WHERE WILL YOU HELP PEOPLE?**. + +## Microsoft Support Policy + +Support for this **PROJECT or PRODUCT** is limited to the resources listed +above. diff --git a/main.py b/main.py index 1ad8072..3da3ace 100644 --- a/main.py +++ b/main.py @@ -1,126 +1,126 @@ -import os - -import redis -from fastapi import FastAPI, HTTPException, Request - -from models import ItemPayload - -app = FastAPI() - -redis_client = redis.StrictRedis(host="0.0.0.0", port=6379, db=0, decode_responses=True) - - -@app.get("/") -def home(request: Request) -> dict[str, str]: - url: str = ( - f"https://{os.getenv('CODESPACE_NAME')}-8000.{os.getenv('GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN')}/" - if os.getenv("CODESPACE_NAME") - else str(request.base_url) - ) - return { - "message": f"Navigate to the following URL to access the Swagger UI: {url}docs" - } - - -# Route to add an item -@app.post("/items/{item_name}/{quantity}") -def add_item(item_name: str, quantity: int) -> dict[str, ItemPayload]: - if quantity <= 0: - raise HTTPException(status_code=400, detail="Quantity must be greater than 0.") - - # Check if item already exists - item_id_str: str | None = redis_client.hget("item_name_to_id", item_name) - - if item_id_str is not None: - item_id = int(item_id_str) - quantity = redis_client.hincrby(f"item_id:{item_id}", "quantity", quantity) - else: - # Generate an id for the item - item_id: int = redis_client.incr("item_ids") - redis_client.hset( - f"item_id:{item_id}", - mapping={ - "item_id": item_id, - "item_name": item_name, - "quantity": quantity, - }, - ) - # Create a set so we can search by name too - redis_client.hset("item_name_to_id", item_name, item_id) - - return { - "item": ItemPayload(item_id=item_id, item_name=item_name, quantity=quantity) - } - - -# Route to list a specific item by id but using Redis -@app.get("/items/{item_id}") -def list_item(item_id: int) -> dict[str, dict[str, str]]: - if not redis_client.hexists(f"item_id:{item_id}", "item_id"): - raise HTTPException(status_code=404, detail="Item not found.") - else: - return {"item": redis_client.hgetall(f"item_id:{item_id}")} - - -@app.get("/items") -def list_items() -> dict[str, list[ItemPayload]]: - items: list[ItemPayload] = [] - stored_items: dict[str, str] = redis_client.hgetall("item_name_to_id") - - for name, id_str in stored_items.items(): - item_id: int = int(id_str) - - item_name_str: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") - if item_name_str is not None: - item_name: str = item_name_str - else: - continue # skip this item if it has no name - - item_quantity_str: str | None = redis_client.hget( - f"item_id:{item_id}", "quantity" - ) - if item_quantity_str is not None: - item_quantity: int = int(item_quantity_str) - else: - item_quantity = 0 - - items.append( - ItemPayload(item_id=item_id, item_name=item_name, quantity=item_quantity) - ) - - return {"items": items} - - -# Route to delete a specific item by id but using Redis -@app.delete("/items/{item_id}") -def delete_item(item_id: int) -> dict[str, str]: - if not redis_client.hexists(f"item_id:{item_id}", "item_id"): - raise HTTPException(status_code=404, detail="Item not found.") - else: - item_name: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") - redis_client.hdel("item_name_to_id", f"{item_name}") - redis_client.delete(f"item_id:{item_id}") - return {"result": "Item deleted."} - - -# Route to remove some quantity of a specific item by id but using Redis -@app.delete("/items/{item_id}/{quantity}") -def remove_quantity(item_id: int, quantity: int) -> dict[str, str]: - if not redis_client.hexists(f"item_id:{item_id}", "item_id"): - raise HTTPException(status_code=404, detail="Item not found.") - - item_quantity: str | None = redis_client.hget(f"item_id:{item_id}", "quantity") - - # if quantity to be removed is higher or equal to item's quantity, delete the item - if item_quantity is None: - existing_quantity: int = 0 - else: - existing_quantity: int = int(item_quantity) - if existing_quantity <= quantity: - item_name: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") - redis_client.hdel("item_name_to_id", f"{item_name}") - redis_client.delete(f"item_id:{item_id}") - return {"result": "Item deleted."} - else: - redis_client.hincrby(f"item_id:{item_id}", "quantity", -quantity) - return {"result": f"{quantity} items removed."} +import os + +import redis +from fastapi import FastAPI, HTTPException, Request + +from models import ItemPayload + +app = FastAPI() + +redis_client = redis.StrictRedis(host="0.0.0.0", port=6379, db=0, decode_responses=True) + + +@app.get("/") +def home(request: Request) -> dict[str, str]: + url: str = ( + f"https://{os.getenv('CODESPACE_NAME')}-8000.{os.getenv('GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN')}/" + if os.getenv("CODESPACE_NAME") + else str(request.base_url) + ) + return { + "message": f"Navigate to the following URL to access the Swagger UI: {url}docs" + } + + +# Route to add an item +@app.post("/items/{item_name}/{quantity}") +def add_item(item_name: str, quantity: int) -> dict[str, ItemPayload]: + if quantity <= 0: + raise HTTPException(status_code=400, detail="Quantity must be greater than 0.") + + # Check if item already exists + item_id_str: str | None = redis_client.hget("item_name_to_id", item_name) + + if item_id_str is not None: + item_id = int(item_id_str) + quantity = redis_client.hincrby(f"item_id:{item_id}", "quantity", quantity) + else: + # Generate an id for the item + item_id: int = redis_client.incr("item_ids") + redis_client.hset( + f"item_id:{item_id}", + mapping={ + "item_id": item_id, + "item_name": item_name, + "quantity": quantity, + }, + ) + # Create a set so we can search by name too + redis_client.hset("item_name_to_id", item_name, item_id) + + return { + "item": ItemPayload(item_id=item_id, item_name=item_name, quantity=quantity) + } + + +# Route to list a specific item by id but using Redis +@app.get("/items/{item_id}") +def list_item(item_id: int) -> dict[str, dict[str, str]]: + if not redis_client.hexists(f"item_id:{item_id}", "item_id"): + raise HTTPException(status_code=404, detail="Item not found.") + else: + return {"item": redis_client.hgetall(f"item_id:{item_id}")} + + +@app.get("/items") +def list_items() -> dict[str, list[ItemPayload]]: + items: list[ItemPayload] = [] + stored_items: dict[str, str] = redis_client.hgetall("item_name_to_id") + + for name, id_str in stored_items.items(): + item_id: int = int(id_str) + + item_name_str: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") + if item_name_str is not None: + item_name: str = item_name_str + else: + continue # skip this item if it has no name + + item_quantity_str: str | None = redis_client.hget( + f"item_id:{item_id}", "quantity" + ) + if item_quantity_str is not None: + item_quantity: int = int(item_quantity_str) + else: + item_quantity = 0 + + items.append( + ItemPayload(item_id=item_id, item_name=item_name, quantity=item_quantity) + ) + + return {"items": items} + + +# Route to delete a specific item by id but using Redis +@app.delete("/items/{item_id}") +def delete_item(item_id: int) -> dict[str, str]: + if not redis_client.hexists(f"item_id:{item_id}", "item_id"): + raise HTTPException(status_code=404, detail="Item not found.") + else: + item_name: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") + redis_client.hdel("item_name_to_id", f"{item_name}") + redis_client.delete(f"item_id:{item_id}") + return {"result": "Item deleted."} + + +# Route to remove some quantity of a specific item by id but using Redis +@app.delete("/items/{item_id}/{quantity}") +def remove_quantity(item_id: int, quantity: int) -> dict[str, str]: + if not redis_client.hexists(f"item_id:{item_id}", "item_id"): + raise HTTPException(status_code=404, detail="Item not found.") + + item_quantity: str | None = redis_client.hget(f"item_id:{item_id}", "quantity") + + # if quantity to be removed is higher or equal to item's quantity, delete the item + if item_quantity is None: + existing_quantity: int = 0 + else: + existing_quantity: int = int(item_quantity) + if existing_quantity <= quantity: + item_name: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") + redis_client.hdel("item_name_to_id", f"{item_name}") + redis_client.delete(f"item_id:{item_id}") + return {"result": "Item deleted."} + else: + redis_client.hincrby(f"item_id:{item_id}", "quantity", -quantity) + return {"result": f"{quantity} items removed."} diff --git a/models.py b/models.py index bba7954..6d6a40c 100644 --- a/models.py +++ b/models.py @@ -1,9 +1,9 @@ -from typing import Optional - -from pydantic import BaseModel - - -class ItemPayload(BaseModel): - item_id: Optional[int] - item_name: str - quantity: int +from typing import Optional + +from pydantic import BaseModel + + +class ItemPayload(BaseModel): + item_id: Optional[int] + item_name: str + quantity: int diff --git a/requirements.txt b/requirements.txt index 6ea752e..7631c08 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,18 @@ -annotated-types==0.6.0 -anyio==3.7.1 -cffi==1.16.0 -click==8.1.7 -cryptography==41.0.4 -fastapi==0.104.0 -h11==0.14.0 -idna==3.4 -pycparser==2.21 -pydantic==2.4.2 -pydantic-core==2.10.1 -redis==5.0.1 -sniffio==1.3.0 -starlette==0.27.0 -types-pyopenssl==23.3.0.0 -types-redis==4.6.0.7 -typing-extensions==4.8.0 -uvicorn==0.23.2 +annotated-types==0.6.0 +anyio==3.7.1 +cffi==1.16.0 +click==8.1.7 +cryptography==41.0.4 +fastapi==0.104.0 +h11==0.14.0 +idna==3.4 +pycparser==2.21 +pydantic==2.4.2 +pydantic-core==2.10.1 +redis==5.0.1 +sniffio==1.3.0 +starlette==0.27.0 +types-pyopenssl==23.3.0.0 +types-redis==4.6.0.7 +typing-extensions==4.8.0 +uvicorn==0.23.2 From 1f4293d7715aae123fdbccb53a4f3490259c8ad7 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sun, 26 May 2024 22:17:45 +0300 Subject: [PATCH 14/43] squash! --- FUNDING.yml => .github/FUNDING.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename FUNDING.yml => .github/FUNDING.yml (100%) diff --git a/FUNDING.yml b/.github/FUNDING.yml similarity index 100% rename from FUNDING.yml rename to .github/FUNDING.yml From ed8a97f59ff9ccf8f64b48a4dd3edb0e6bd0a15f Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Mon, 27 May 2024 17:01:30 +0300 Subject: [PATCH 15/43] squash! --- .devcontainer/devcontainer.json | 31 ------------------------------- .vscode/launch.json | 19 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From e5604b314e82d2513250ef97c3c9f8a12c7f6d0a Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Thu, 6 Jun 2024 01:33:17 +0300 Subject: [PATCH 16/43] squash! --- .devcontainer/devcontainer.json | 31 ------------------------------- .vscode/launch.json | 19 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From 62d5ce87937ee048fb1d918a12b90777cab4dfde Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sat, 8 Jun 2024 07:34:40 +0300 Subject: [PATCH 17/43] squash! --- .devcontainer/devcontainer.json | 31 ------------------------------- .vscode/launch.json | 19 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From 4c5aaf788bc841e2c66e7548dd43c74e6db813b8 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sun, 9 Jun 2024 19:19:11 +0300 Subject: [PATCH 18/43] squash! --- .devcontainer/devcontainer.json | 31 ------------------------------- .vscode/launch.json | 19 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From 36fd6e1ea657df3df12a45d2b1810900d4319088 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Wed, 12 Jun 2024 22:04:57 +0300 Subject: [PATCH 19/43] squash! --- .github/dependabot.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ee3d10a..4242a05 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,6 +1,14 @@ -version: 2 -updates: - - package-ecosystem: "pip" - directory: "/" # Location of package manifests - schedule: - interval: "weekly" +version: 2 +enable-beta-ecosystems: true + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" + versioning-strategy: increase From da31244225d7b4f474bb01c8f675638486af441b Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Thu, 13 Jun 2024 18:30:04 +0300 Subject: [PATCH 20/43] squash! --- .devcontainer/devcontainer.json | 31 ------------------------------- .vscode/launch.json | 19 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From eff53cf2a7eca0698373d8c873fa44a4311f2e73 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sun, 16 Jun 2024 16:43:33 +0300 Subject: [PATCH 21/43] squash! --- .devcontainer/devcontainer.json | 31 ------------------------------- .vscode/launch.json | 19 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From a6a46dc08ebc907366eeb6c28dcb180a138618bb Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Mon, 17 Jun 2024 17:52:37 +0300 Subject: [PATCH 22/43] squash! --- .devcontainer/devcontainer.json | 31 ------------------------------- .vscode/launch.json | 19 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From c3294c146b15f41901b368163c151317da3b2034 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Wed, 19 Jun 2024 21:57:37 +0300 Subject: [PATCH 23/43] squash! --- .devcontainer/devcontainer.json | 31 ------------------------------- .vscode/launch.json | 19 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From f511b7f2e5aaa949dd31c692fcbad6e998d98f80 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Thu, 27 Jun 2024 10:56:42 +0300 Subject: [PATCH 24/43] squash! --- .github/dependabot.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ee3d10a..4242a05 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,6 +1,14 @@ -version: 2 -updates: - - package-ecosystem: "pip" - directory: "/" # Location of package manifests - schedule: - interval: "weekly" +version: 2 +enable-beta-ecosystems: true + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" + versioning-strategy: increase From ff7c02355a4ef7602f3b2a5874b2fcc71e7df9f4 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Mon, 8 Jul 2024 16:15:41 +0300 Subject: [PATCH 25/43] squash! --- CODE_OF_CONDUCT.md | 149 +++++++++++++++++++++++++++++++++++++++++++-- LICENSE | 41 ++++++------- 2 files changed, 163 insertions(+), 27 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index f9ba8cf..d35c668 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,9 +1,146 @@ -# Microsoft Open Source Code of Conduct +# Code of Conduct -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +## Our Pledge -Resources: +Welcome to our community! We are committed to creating a welcoming and inclusive +environment for all contributors. As members, contributors, and leaders, we +pledge to make participation in our community a harassment-free experience for +everyone, regardless of: -- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) -- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) -- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns +- Age +- Body size +- Visible or invisible disability +- Ethnicity +- Sex characteristics +- Gender identity and expression +- Level of experience +- Education +- Socio-economic status +- Nationality +- Personal appearance +- Race +- Caste +- Color +- Religion +- Sexual identity and orientation + +We promise to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +- Focusing on what is best not just for us as individuals but for the overall + community + +Examples of unacceptable behavior include: + +- The use of sexualized language or imagery, and sexual attention or advances + of any kind +- Trolling, insulting, or derogatory comments, and personal or political + attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, + without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior. They will take appropriate and fair corrective action in +response to any behavior they deem inappropriate, threatening, offensive, or +harmful. This may include removing, editing, or rejecting comments, commits, +code, wiki edits, issues, and other contributions that do not align with this +Code of Conduct. Community leaders will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +Community@PlayForm.Cloud. All complaints will be reviewed and investigated +promptly and fairly. All community leaders are obligated to respect the privacy +and security of the reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations + +Thank you for being part of our community and helping us create a safe and +respectful environment for everyone! diff --git a/LICENSE b/LICENSE index 62f454e..f236d76 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,20 @@ -MIT License - -Copyright (c) 2023 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +MIT License + +Copyright (c) 2023-2024 PlayForm + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 60ea69ca7c4a53a7132a76fbbbb6e0cbac25c2e1 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Tue, 9 Jul 2024 22:09:15 +0300 Subject: [PATCH 26/43] squash! --- .github/workflows/Dependabot.yml | 4 ++-- .github/workflows/GitHub.yml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Dependabot.yml b/.github/workflows/Dependabot.yml index e6091e5..387fece 100644 --- a/.github/workflows/Dependabot.yml +++ b/.github/workflows/Dependabot.yml @@ -20,7 +20,7 @@ jobs: if: ${{ github.actor == 'dependabot[bot]' }} steps: - - uses: dependabot/fetch-metadata@v2.1.0 + - uses: dependabot/fetch-metadata@v2.2.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" @@ -35,7 +35,7 @@ jobs: if: ${{ github.actor == 'dependabot[bot]' }} steps: - - uses: dependabot/fetch-metadata@v2.1.0 + - uses: dependabot/fetch-metadata@v2.2.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/GitHub.yml b/.github/workflows/GitHub.yml index 5e814e3..7b1e399 100644 --- a/.github/workflows/GitHub.yml +++ b/.github/workflows/GitHub.yml @@ -48,6 +48,7 @@ jobs: STNOUPGRADE: 1 STRIPE_CLI_TELEMETRY_OPTOUT: 1 TELEMETRY_DISABLED: 1 + TERRAFORM_TELEMETRY: 0 steps: - uses: pozil/auto-assign-issue@v2.0.0 From 2f77302dc20351aaaa76a623350e055dc634ef0a Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Fri, 12 Jul 2024 02:08:17 +0300 Subject: [PATCH 27/43] squash! --- .github/FUNDING.yml | 1 - .github/dependabot.yml | 14 --- .github/workflows/Dependabot.yml | 45 -------- .github/workflows/GitHub.yml | 58 ---------- .github/workflows/test-application.yml | 33 ------ .gitignore | 106 ------------------ CODE_OF_CONDUCT.md | 146 ------------------------- LICENSE | 20 ---- README.md | 48 -------- SECURITY.md | 41 ------- SUPPORT.md | 25 ----- flushdb.py | 9 -- main.py | 126 --------------------- models.py | 9 -- requirements.txt | 18 --- 15 files changed, 699 deletions(-) delete mode 100644 .github/FUNDING.yml delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/Dependabot.yml delete mode 100644 .github/workflows/GitHub.yml delete mode 100644 .github/workflows/test-application.yml delete mode 100644 .gitignore delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 LICENSE delete mode 100644 README.md delete mode 100644 SECURITY.md delete mode 100644 SUPPORT.md delete mode 100644 flushdb.py delete mode 100644 main.py delete mode 100644 models.py delete mode 100644 requirements.txt diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 12f5195..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -open_collective: code-editor-land diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 4242a05..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: 2 -enable-beta-ecosystems: true - -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" - - - package-ecosystem: "pip" - directory: "/" - schedule: - interval: "daily" - versioning-strategy: increase diff --git a/.github/workflows/Dependabot.yml b/.github/workflows/Dependabot.yml deleted file mode 100644 index 387fece..0000000 --- a/.github/workflows/Dependabot.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Dependabot - -concurrency: - group: Dependabot-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - security-events: write - contents: write - pull-requests: write - -on: - workflow_dispatch: - pull_request: - -jobs: - Approve: - runs-on: ubuntu-latest - - if: ${{ github.actor == 'dependabot[bot]' }} - - steps: - - uses: dependabot/fetch-metadata@v2.2.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - run: gh pr review --approve "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - Merge: - runs-on: ubuntu-latest - - if: ${{ github.actor == 'dependabot[bot]' }} - - steps: - - uses: dependabot/fetch-metadata@v2.2.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - run: gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/GitHub.yml b/.github/workflows/GitHub.yml deleted file mode 100644 index 7b1e399..0000000 --- a/.github/workflows/GitHub.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: GitHub - -concurrency: - group: GitHub-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - issues: write - pull-requests: write - -on: - issues: - types: [opened] - pull_request: - types: [opened] - -jobs: - Assign: - runs-on: ubuntu-latest - - env: - ADBLOCK: true - ASTRO_TELEMETRY_DISABLED: 1 - AUTOMATEDLAB_TELEMETRY_OPTOUT: 1 - AZURE_CORE_COLLECT_TELEMETRY: 0 - CHOOSENIM_NO_ANALYTICS: 1 - DIEZ_DO_NOT_TRACK: 1 - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT: 1 - DO_NOT_TRACK: 1 - ET_NO_TELEMETRY: 1 - GATSBY_TELEMETRY_DISABLED: 1 - GATSBY_TELEMETRY_OPTOUT: 1 - GATSBY_TELEMETRY_OPT_OUT: 1 - GRIT_TELEMETRY_DISABLED: 1 - HASURA_GRAPHQL_ENABLE_TELEMETRY: false - HINT_TELEMETRY: off - HOMEBREW_NO_ANALYTICS: 1 - INFLUXD_REPORTING_DISABLED: true - ITERATIVE_DO_NOT_TRACK: 1 - NEXT_TELEMETRY_DEBUG: 1 - NEXT_TELEMETRY_DISABLED: 1 - NG_CLI_ANALYTICS: false - NUXT_TELEMETRY_DISABLED: 1 - PIN_DO_NOT_TRACK: 1 - POWERSHELL_TELEMETRY_OPTOUT: 1 - SAM_CLI_TELEMETRY: 0 - STNOUPGRADE: 1 - STRIPE_CLI_TELEMETRY_OPTOUT: 1 - TELEMETRY_DISABLED: 1 - TERRAFORM_TELEMETRY: 0 - - steps: - - uses: pozil/auto-assign-issue@v2.0.0 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - assignees: NikolaRHristov - numOfAssignee: 1 diff --git a/.github/workflows/test-application.yml b/.github/workflows/test-application.yml deleted file mode 100644 index 0b99df1..0000000 --- a/.github/workflows/test-application.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Test Application - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - env: - PORT: 8000 - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Start the app - run: uvicorn main:app --host 0.0.0.0 --port ${{ env.PORT }} & - - - name: Sleep for 1 minute - run: sleep 60 - - - name: Stop the app - run: pkill -f 'uvicorn main:app' - diff --git a/.gitignore b/.gitignore deleted file mode 100644 index f75400b..0000000 --- a/.gitignore +++ /dev/null @@ -1,106 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ - -settings.json \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index d35c668..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,146 +0,0 @@ -# Code of Conduct - -## Our Pledge - -Welcome to our community! We are committed to creating a welcoming and inclusive -environment for all contributors. As members, contributors, and leaders, we -pledge to make participation in our community a harassment-free experience for -everyone, regardless of: - -- Age -- Body size -- Visible or invisible disability -- Ethnicity -- Sex characteristics -- Gender identity and expression -- Level of experience -- Education -- Socio-economic status -- Nationality -- Personal appearance -- Race -- Caste -- Color -- Religion -- Sexual identity and orientation - -We promise to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. - -## Our Standards - -Examples of behavior that contributes to a positive environment for our -community include: - -- Demonstrating empathy and kindness toward other people -- Being respectful of differing opinions, viewpoints, and experiences -- Giving and gracefully accepting constructive feedback -- Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -- Focusing on what is best not just for us as individuals but for the overall - community - -Examples of unacceptable behavior include: - -- The use of sexualized language or imagery, and sexual attention or advances - of any kind -- Trolling, insulting, or derogatory comments, and personal or political - attacks -- Public or private harassment -- Publishing others' private information, such as a physical or email address, - without their explicit permission -- Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior. They will take appropriate and fair corrective action in -response to any behavior they deem inappropriate, threatening, offensive, or -harmful. This may include removing, editing, or rejecting comments, commits, -code, wiki edits, issues, and other contributions that do not align with this -Code of Conduct. Community leaders will communicate reasons for moderation -decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at -Community@PlayForm.Cloud. All complaints will be reviewed and investigated -promptly and fairly. All community leaders are obligated to respect the privacy -and security of the reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of -actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or permanent -ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the -community. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.1, available at -[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. -Community Impact Guidelines were inspired by [Mozilla's code of conduct -enforcement ladder][Mozilla CoC]. - -For answers to common questions about this code of conduct, see the FAQ at -[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at -[https://www.contributor-covenant.org/translations][translations]. - -[homepage]: https://www.contributor-covenant.org -[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html -[Mozilla CoC]: https://github.com/mozilla/diversity -[FAQ]: https://www.contributor-covenant.org/faq -[translations]: https://www.contributor-covenant.org/translations - -Thank you for being part of our community and helping us create a safe and -respectful environment for everyone! diff --git a/LICENSE b/LICENSE deleted file mode 100644 index f236d76..0000000 --- a/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -MIT License - -Copyright (c) 2023-2024 PlayForm - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md deleted file mode 100644 index 7c991dd..0000000 --- a/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# Python/FastAPI Tutorial for Visual Studio Code -This sample contains the completed program from the tutorial: [FastAPI in Visual Studio Code](https://code.visualstudio.com/docs/python/tutorial-fastapi). Immediate steps are not included. - -## Run the app using GitHub Codespaces -[GitHub Codespaces](https://github.com/features/codespaces) provides cloud-powered development environments that work how and where you want it to. To learn how to set up a GitHub Codespace for this repository, check the [documentation](https://docs.github.com/en/codespaces/developing-in-codespaces/creating-a-codespace-for-a-repository#creating-a-codespace-for-a-repository). - -Once you open this repository in GitHub Codespaces, you can press **F5** to start the debugger and run the application. - -Once it's ready, you will see a notification with a button `Open in the Browser`. Clicking the button will open your application on the browser. You can then add `/docs` to the end of the URL to access the Swagger UI and interact with the application! - -## Run the app locally in VS Code - -There are diffent ways you can run this app locally in VS Code depending on your operating system. To get started, first clone this project on your machine and then open it in VS Code (**File** > **Open Folder...**). - -### Windows -To run this app locally in VS Code on Windows, you can use either [WSL](https://learn.microsoft.com/en-us/windows/wsl/) (Windows Subsystem for Linux) or [Docker](https://www.docker.com/products/docker-desktop). - -#### Docker Containers -1. Make sure you have [Docker installed](https://www.docker.com/products/docker-desktop) -1. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) -1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and run the "Dev Container: Reopen in Container" command. -1. Press **F5** to debug your application! - -#### WSL -1. Make sure you have [WSL installed](https://learn.microsoft.com/en-us/windows/wsl/) -1. Install the [WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) for VS Code -1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and run the "WSL: Reopen Folder in WSL" command -1. Follow the remaining steps for [macOS/Linux](#macos--linux) below. - -### macOS / Linux - -1. Install the [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) for VS Code -1. Run the "Python: Create Environment" command in the Command Palette -1. Select `Venv`, the latest available version of Python and then the `requirements.txt` file to install the dependencies. -1. Press **F5** to run your application! - -## Contributing -Contributions to the sample are welcome! When submitting changes, also consider submitting matching changes to the tutorial, the source file for which is [tutorial-fastapi.md](https://github.com/Microsoft/vscode-docs/blob/master/docs/python/tutorial-fastapi.md). - -Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. - -When you submit a pull request, a CLA-bot automatically determines whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. - -## Additional details - -* This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -* For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or -* Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index b3c89ef..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,41 +0,0 @@ - - -## Security - -Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin). - -If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below. - -## Reporting Security Issues - -**Please do not report security vulnerabilities through public GitHub issues.** - -Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report). - -If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp). - -You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). - -Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: - - * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) - * Full paths of source file(s) related to the manifestation of the issue - * The location of the affected source code (tag/branch/commit or direct URL) - * Any special configuration required to reproduce the issue - * Step-by-step instructions to reproduce the issue - * Proof-of-concept or exploit code (if possible) - * Impact of the issue, including how an attacker might exploit the issue - -This information will help us triage your report more quickly. - -If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs. - -## Preferred Languages - -We prefer all communications to be in English. - -## Policy - -Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd). - - diff --git a/SUPPORT.md b/SUPPORT.md deleted file mode 100644 index 291d4d4..0000000 --- a/SUPPORT.md +++ /dev/null @@ -1,25 +0,0 @@ -# TODO: The maintainer of this repo has not yet edited this file - -**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? - -- **No CSS support:** Fill out this template with information about how to file issues and get help. -- **Yes CSS support:** Fill out an intake form at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work with/help you to determine next steps. -- **Not sure?** Fill out an intake as though the answer were "Yes". CSS will help you decide. - -*Then remove this first heading from this SUPPORT.MD file before publishing your repo.* - -# Support - -## How to file issues and get help - -This project uses GitHub Issues to track bugs and feature requests. Please search the existing -issues before filing new issues to avoid duplicates. For new issues, file your bug or -feature request as a new Issue. - -For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE -FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER -CHANNEL. WHERE WILL YOU HELP PEOPLE?**. - -## Microsoft Support Policy - -Support for this **PROJECT or PRODUCT** is limited to the resources listed above. diff --git a/flushdb.py b/flushdb.py deleted file mode 100644 index 65442ad..0000000 --- a/flushdb.py +++ /dev/null @@ -1,9 +0,0 @@ -""" -This module is used to interact with a Redis database. - -WARNING: This script will flush the entire Redis database. Use with caution. -""" -import redis - -redis_client = redis.StrictRedis(host="0.0.0.0", port=6379, db=0, decode_responses=True) -redis_client.flushdb() diff --git a/main.py b/main.py deleted file mode 100644 index 1ad8072..0000000 --- a/main.py +++ /dev/null @@ -1,126 +0,0 @@ -import os - -import redis -from fastapi import FastAPI, HTTPException, Request - -from models import ItemPayload - -app = FastAPI() - -redis_client = redis.StrictRedis(host="0.0.0.0", port=6379, db=0, decode_responses=True) - - -@app.get("/") -def home(request: Request) -> dict[str, str]: - url: str = ( - f"https://{os.getenv('CODESPACE_NAME')}-8000.{os.getenv('GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN')}/" - if os.getenv("CODESPACE_NAME") - else str(request.base_url) - ) - return { - "message": f"Navigate to the following URL to access the Swagger UI: {url}docs" - } - - -# Route to add an item -@app.post("/items/{item_name}/{quantity}") -def add_item(item_name: str, quantity: int) -> dict[str, ItemPayload]: - if quantity <= 0: - raise HTTPException(status_code=400, detail="Quantity must be greater than 0.") - - # Check if item already exists - item_id_str: str | None = redis_client.hget("item_name_to_id", item_name) - - if item_id_str is not None: - item_id = int(item_id_str) - quantity = redis_client.hincrby(f"item_id:{item_id}", "quantity", quantity) - else: - # Generate an id for the item - item_id: int = redis_client.incr("item_ids") - redis_client.hset( - f"item_id:{item_id}", - mapping={ - "item_id": item_id, - "item_name": item_name, - "quantity": quantity, - }, - ) - # Create a set so we can search by name too - redis_client.hset("item_name_to_id", item_name, item_id) - - return { - "item": ItemPayload(item_id=item_id, item_name=item_name, quantity=quantity) - } - - -# Route to list a specific item by id but using Redis -@app.get("/items/{item_id}") -def list_item(item_id: int) -> dict[str, dict[str, str]]: - if not redis_client.hexists(f"item_id:{item_id}", "item_id"): - raise HTTPException(status_code=404, detail="Item not found.") - else: - return {"item": redis_client.hgetall(f"item_id:{item_id}")} - - -@app.get("/items") -def list_items() -> dict[str, list[ItemPayload]]: - items: list[ItemPayload] = [] - stored_items: dict[str, str] = redis_client.hgetall("item_name_to_id") - - for name, id_str in stored_items.items(): - item_id: int = int(id_str) - - item_name_str: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") - if item_name_str is not None: - item_name: str = item_name_str - else: - continue # skip this item if it has no name - - item_quantity_str: str | None = redis_client.hget( - f"item_id:{item_id}", "quantity" - ) - if item_quantity_str is not None: - item_quantity: int = int(item_quantity_str) - else: - item_quantity = 0 - - items.append( - ItemPayload(item_id=item_id, item_name=item_name, quantity=item_quantity) - ) - - return {"items": items} - - -# Route to delete a specific item by id but using Redis -@app.delete("/items/{item_id}") -def delete_item(item_id: int) -> dict[str, str]: - if not redis_client.hexists(f"item_id:{item_id}", "item_id"): - raise HTTPException(status_code=404, detail="Item not found.") - else: - item_name: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") - redis_client.hdel("item_name_to_id", f"{item_name}") - redis_client.delete(f"item_id:{item_id}") - return {"result": "Item deleted."} - - -# Route to remove some quantity of a specific item by id but using Redis -@app.delete("/items/{item_id}/{quantity}") -def remove_quantity(item_id: int, quantity: int) -> dict[str, str]: - if not redis_client.hexists(f"item_id:{item_id}", "item_id"): - raise HTTPException(status_code=404, detail="Item not found.") - - item_quantity: str | None = redis_client.hget(f"item_id:{item_id}", "quantity") - - # if quantity to be removed is higher or equal to item's quantity, delete the item - if item_quantity is None: - existing_quantity: int = 0 - else: - existing_quantity: int = int(item_quantity) - if existing_quantity <= quantity: - item_name: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") - redis_client.hdel("item_name_to_id", f"{item_name}") - redis_client.delete(f"item_id:{item_id}") - return {"result": "Item deleted."} - else: - redis_client.hincrby(f"item_id:{item_id}", "quantity", -quantity) - return {"result": f"{quantity} items removed."} diff --git a/models.py b/models.py deleted file mode 100644 index bba7954..0000000 --- a/models.py +++ /dev/null @@ -1,9 +0,0 @@ -from typing import Optional - -from pydantic import BaseModel - - -class ItemPayload(BaseModel): - item_id: Optional[int] - item_name: str - quantity: int diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 6ea752e..0000000 --- a/requirements.txt +++ /dev/null @@ -1,18 +0,0 @@ -annotated-types==0.6.0 -anyio==3.7.1 -cffi==1.16.0 -click==8.1.7 -cryptography==41.0.4 -fastapi==0.104.0 -h11==0.14.0 -idna==3.4 -pycparser==2.21 -pydantic==2.4.2 -pydantic-core==2.10.1 -redis==5.0.1 -sniffio==1.3.0 -starlette==0.27.0 -types-pyopenssl==23.3.0.0 -types-redis==4.6.0.7 -typing-extensions==4.8.0 -uvicorn==0.23.2 From ff4d4032f6b8f54ec5d7a799c04526669640ae48 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sat, 13 Jul 2024 03:25:41 +0300 Subject: [PATCH 28/43] squash! --- .devcontainer/devcontainer.json | 31 ------------------------------- .vscode/launch.json | 19 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From 11d2ec01b1507251ee9e3ee1351ff8f7c70222b4 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sun, 14 Jul 2024 03:14:31 +0300 Subject: [PATCH 29/43] squash! --- .devcontainer/devcontainer.json | 31 ------------------------------- .vscode/launch.json | 19 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From f0b9d608798c0ad89552ece8ef5b168a713b4957 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sun, 14 Jul 2024 16:38:31 +0300 Subject: [PATCH 30/43] squash! --- .devcontainer/devcontainer.json | 31 ------------------------------- .vscode/launch.json | 19 ------------------- 2 files changed, 50 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From 96f30e441c4f06f2b26df32c8e8e4f2ec646103f Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Mon, 22 Jul 2024 19:02:28 +0300 Subject: [PATCH 31/43] --- .github/dependabot.yml | 20 +++++++---- .github/workflows/Dependabot.yml | 45 +++++++++++++++++++++++++ .github/workflows/GitHub.yml | 58 ++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/Dependabot.yml create mode 100644 .github/workflows/GitHub.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ee3d10a..4242a05 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,6 +1,14 @@ -version: 2 -updates: - - package-ecosystem: "pip" - directory: "/" # Location of package manifests - schedule: - interval: "weekly" +version: 2 +enable-beta-ecosystems: true + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" + versioning-strategy: increase diff --git a/.github/workflows/Dependabot.yml b/.github/workflows/Dependabot.yml new file mode 100644 index 0000000..387fece --- /dev/null +++ b/.github/workflows/Dependabot.yml @@ -0,0 +1,45 @@ +name: Dependabot + +concurrency: + group: Dependabot-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + security-events: write + contents: write + pull-requests: write + +on: + workflow_dispatch: + pull_request: + +jobs: + Approve: + runs-on: ubuntu-latest + + if: ${{ github.actor == 'dependabot[bot]' }} + + steps: + - uses: dependabot/fetch-metadata@v2.2.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + Merge: + runs-on: ubuntu-latest + + if: ${{ github.actor == 'dependabot[bot]' }} + + steps: + - uses: dependabot/fetch-metadata@v2.2.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/GitHub.yml b/.github/workflows/GitHub.yml new file mode 100644 index 0000000..7b1e399 --- /dev/null +++ b/.github/workflows/GitHub.yml @@ -0,0 +1,58 @@ +name: GitHub + +concurrency: + group: GitHub-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + issues: write + pull-requests: write + +on: + issues: + types: [opened] + pull_request: + types: [opened] + +jobs: + Assign: + runs-on: ubuntu-latest + + env: + ADBLOCK: true + ASTRO_TELEMETRY_DISABLED: 1 + AUTOMATEDLAB_TELEMETRY_OPTOUT: 1 + AZURE_CORE_COLLECT_TELEMETRY: 0 + CHOOSENIM_NO_ANALYTICS: 1 + DIEZ_DO_NOT_TRACK: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT: 1 + DO_NOT_TRACK: 1 + ET_NO_TELEMETRY: 1 + GATSBY_TELEMETRY_DISABLED: 1 + GATSBY_TELEMETRY_OPTOUT: 1 + GATSBY_TELEMETRY_OPT_OUT: 1 + GRIT_TELEMETRY_DISABLED: 1 + HASURA_GRAPHQL_ENABLE_TELEMETRY: false + HINT_TELEMETRY: off + HOMEBREW_NO_ANALYTICS: 1 + INFLUXD_REPORTING_DISABLED: true + ITERATIVE_DO_NOT_TRACK: 1 + NEXT_TELEMETRY_DEBUG: 1 + NEXT_TELEMETRY_DISABLED: 1 + NG_CLI_ANALYTICS: false + NUXT_TELEMETRY_DISABLED: 1 + PIN_DO_NOT_TRACK: 1 + POWERSHELL_TELEMETRY_OPTOUT: 1 + SAM_CLI_TELEMETRY: 0 + STNOUPGRADE: 1 + STRIPE_CLI_TELEMETRY_OPTOUT: 1 + TELEMETRY_DISABLED: 1 + TERRAFORM_TELEMETRY: 0 + + steps: + - uses: pozil/auto-assign-issue@v2.0.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + assignees: NikolaRHristov + numOfAssignee: 1 From 65bcc9380299d5b38f4dc08c8cc1e453bbe24d02 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Tue, 23 Jul 2024 11:37:23 +0300 Subject: [PATCH 32/43] --- .github/dependabot.yml | 14 -------- .github/workflows/Dependabot.yml | 45 ------------------------- .github/workflows/GitHub.yml | 58 -------------------------------- 3 files changed, 117 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/Dependabot.yml delete mode 100644 .github/workflows/GitHub.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 4242a05..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: 2 -enable-beta-ecosystems: true - -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" - - - package-ecosystem: "pip" - directory: "/" - schedule: - interval: "daily" - versioning-strategy: increase diff --git a/.github/workflows/Dependabot.yml b/.github/workflows/Dependabot.yml deleted file mode 100644 index 387fece..0000000 --- a/.github/workflows/Dependabot.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Dependabot - -concurrency: - group: Dependabot-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - security-events: write - contents: write - pull-requests: write - -on: - workflow_dispatch: - pull_request: - -jobs: - Approve: - runs-on: ubuntu-latest - - if: ${{ github.actor == 'dependabot[bot]' }} - - steps: - - uses: dependabot/fetch-metadata@v2.2.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - run: gh pr review --approve "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - Merge: - runs-on: ubuntu-latest - - if: ${{ github.actor == 'dependabot[bot]' }} - - steps: - - uses: dependabot/fetch-metadata@v2.2.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - run: gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/GitHub.yml b/.github/workflows/GitHub.yml deleted file mode 100644 index 7b1e399..0000000 --- a/.github/workflows/GitHub.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: GitHub - -concurrency: - group: GitHub-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - issues: write - pull-requests: write - -on: - issues: - types: [opened] - pull_request: - types: [opened] - -jobs: - Assign: - runs-on: ubuntu-latest - - env: - ADBLOCK: true - ASTRO_TELEMETRY_DISABLED: 1 - AUTOMATEDLAB_TELEMETRY_OPTOUT: 1 - AZURE_CORE_COLLECT_TELEMETRY: 0 - CHOOSENIM_NO_ANALYTICS: 1 - DIEZ_DO_NOT_TRACK: 1 - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT: 1 - DO_NOT_TRACK: 1 - ET_NO_TELEMETRY: 1 - GATSBY_TELEMETRY_DISABLED: 1 - GATSBY_TELEMETRY_OPTOUT: 1 - GATSBY_TELEMETRY_OPT_OUT: 1 - GRIT_TELEMETRY_DISABLED: 1 - HASURA_GRAPHQL_ENABLE_TELEMETRY: false - HINT_TELEMETRY: off - HOMEBREW_NO_ANALYTICS: 1 - INFLUXD_REPORTING_DISABLED: true - ITERATIVE_DO_NOT_TRACK: 1 - NEXT_TELEMETRY_DEBUG: 1 - NEXT_TELEMETRY_DISABLED: 1 - NG_CLI_ANALYTICS: false - NUXT_TELEMETRY_DISABLED: 1 - PIN_DO_NOT_TRACK: 1 - POWERSHELL_TELEMETRY_OPTOUT: 1 - SAM_CLI_TELEMETRY: 0 - STNOUPGRADE: 1 - STRIPE_CLI_TELEMETRY_OPTOUT: 1 - TELEMETRY_DISABLED: 1 - TERRAFORM_TELEMETRY: 0 - - steps: - - uses: pozil/auto-assign-issue@v2.0.0 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - assignees: NikolaRHristov - numOfAssignee: 1 From 6ce49a09761e7b8fb01767ab6e659afe7094357e Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Thu, 25 Jul 2024 14:07:11 +0300 Subject: [PATCH 33/43] --- .github/workflows/test-application.yml | 33 -------------------------- 1 file changed, 33 deletions(-) delete mode 100644 .github/workflows/test-application.yml diff --git a/.github/workflows/test-application.yml b/.github/workflows/test-application.yml deleted file mode 100644 index 0b99df1..0000000 --- a/.github/workflows/test-application.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Test Application - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - env: - PORT: 8000 - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Start the app - run: uvicorn main:app --host 0.0.0.0 --port ${{ env.PORT }} & - - - name: Sleep for 1 minute - run: sleep 60 - - - name: Stop the app - run: pkill -f 'uvicorn main:app' - From 562b6c85d2e86c34119a8b8f71918635c503b5a0 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sun, 28 Jul 2024 00:51:36 +0300 Subject: [PATCH 34/43] --- CODE_OF_CONDUCT.md | 10 +++--- README.md | 82 ++++++++++++++++++++++++++++++++++------------ SECURITY.md | 51 +++++++++++++++++++--------- SUPPORT.md | 35 ++++++++++++-------- flushdb.py | 1 + 5 files changed, 125 insertions(+), 54 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index f9ba8cf..bb1fb9a 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,9 +1,11 @@ # Microsoft Open Source Code of Conduct -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). Resources: -- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) -- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) -- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns +- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) +- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with + questions or concerns diff --git a/README.md b/README.md index 7c991dd..11ca4bf 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,88 @@ # Python/FastAPI Tutorial for Visual Studio Code -This sample contains the completed program from the tutorial: [FastAPI in Visual Studio Code](https://code.visualstudio.com/docs/python/tutorial-fastapi). Immediate steps are not included. + +This sample contains the completed program from the tutorial: +[FastAPI in Visual Studio Code](https://code.visualstudio.com/docs/python/tutorial-fastapi). +Immediate steps are not included. ## Run the app using GitHub Codespaces -[GitHub Codespaces](https://github.com/features/codespaces) provides cloud-powered development environments that work how and where you want it to. To learn how to set up a GitHub Codespace for this repository, check the [documentation](https://docs.github.com/en/codespaces/developing-in-codespaces/creating-a-codespace-for-a-repository#creating-a-codespace-for-a-repository). -Once you open this repository in GitHub Codespaces, you can press **F5** to start the debugger and run the application. +[GitHub Codespaces](https://github.com/features/codespaces) provides +cloud-powered development environments that work how and where you want it to. +To learn how to set up a GitHub Codespace for this repository, check the +[documentation](https://docs.github.com/en/codespaces/developing-in-codespaces/creating-a-codespace-for-a-repository#creating-a-codespace-for-a-repository). + +Once you open this repository in GitHub Codespaces, you can press **F5** to +start the debugger and run the application. -Once it's ready, you will see a notification with a button `Open in the Browser`. Clicking the button will open your application on the browser. You can then add `/docs` to the end of the URL to access the Swagger UI and interact with the application! +Once it's ready, you will see a notification with a button +`Open in the Browser`. Clicking the button will open your application on the +browser. You can then add `/docs` to the end of the URL to access the Swagger UI +and interact with the application! ## Run the app locally in VS Code - -There are diffent ways you can run this app locally in VS Code depending on your operating system. To get started, first clone this project on your machine and then open it in VS Code (**File** > **Open Folder...**). + +There are diffent ways you can run this app locally in VS Code depending on your +operating system. To get started, first clone this project on your machine and +then open it in VS Code (**File** > **Open Folder...**). ### Windows -To run this app locally in VS Code on Windows, you can use either [WSL](https://learn.microsoft.com/en-us/windows/wsl/) (Windows Subsystem for Linux) or [Docker](https://www.docker.com/products/docker-desktop). + +To run this app locally in VS Code on Windows, you can use either +[WSL](https://learn.microsoft.com/en-us/windows/wsl/) (Windows Subsystem for +Linux) or [Docker](https://www.docker.com/products/docker-desktop). #### Docker Containers -1. Make sure you have [Docker installed](https://www.docker.com/products/docker-desktop) -1. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) -1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and run the "Dev Container: Reopen in Container" command. + +1. Make sure you have + [Docker installed](https://www.docker.com/products/docker-desktop) +1. Install the + [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) +1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and + run the "Dev Container: Reopen in Container" command. 1. Press **F5** to debug your application! #### WSL -1. Make sure you have [WSL installed](https://learn.microsoft.com/en-us/windows/wsl/) -1. Install the [WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) for VS Code -1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and run the "WSL: Reopen Folder in WSL" command + +1. Make sure you have + [WSL installed](https://learn.microsoft.com/en-us/windows/wsl/) +1. Install the + [WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) + for VS Code +1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and + run the "WSL: Reopen Folder in WSL" command 1. Follow the remaining steps for [macOS/Linux](#macos--linux) below. ### macOS / Linux -1. Install the [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) for VS Code +1. Install the + [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) + for VS Code 1. Run the "Python: Create Environment" command in the Command Palette -1. Select `Venv`, the latest available version of Python and then the `requirements.txt` file to install the dependencies. +1. Select `Venv`, the latest available version of Python and then the + `requirements.txt` file to install the dependencies. 1. Press **F5** to run your application! ## Contributing -Contributions to the sample are welcome! When submitting changes, also consider submitting matching changes to the tutorial, the source file for which is [tutorial-fastapi.md](https://github.com/Microsoft/vscode-docs/blob/master/docs/python/tutorial-fastapi.md). -Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com. +Contributions to the sample are welcome! When submitting changes, also consider +submitting matching changes to the tutorial, the source file for which is +[tutorial-fastapi.md](https://github.com/Microsoft/vscode-docs/blob/master/docs/python/tutorial-fastapi.md). + +Most contributions require you to agree to a Contributor License Agreement (CLA) +declaring that you have the right to, and actually do, grant us the rights to +use your contribution. For details, visit https://cla.microsoft.com. -When you submit a pull request, a CLA-bot automatically determines whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. +When you submit a pull request, a CLA-bot automatically determines whether you +need to provide a CLA and decorate the PR appropriately (e.g., label, comment). +Simply follow the instructions provided by the bot. You will only need to do +this once across all repos using our CLA. ## Additional details -* This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -* For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or -* Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. +- This project has adopted the + [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +- For more information see the + [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) + or +- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any + additional questions or comments. diff --git a/SECURITY.md b/SECURITY.md index b3c89ef..27d107b 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,33 +2,53 @@ ## Security -Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin). +Microsoft takes the security of our software products and services seriously, +which includes all source code repositories managed through our GitHub +organizations, which include [Microsoft](https://github.com/Microsoft), +[Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), +[AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin). -If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below. +If you believe you have found a security vulnerability in any Microsoft-owned +repository that meets +[Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), +please report it to us as described below. ## Reporting Security Issues **Please do not report security vulnerabilities through public GitHub issues.** -Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report). +Instead, please report them to the Microsoft Security Response Center (MSRC) at +[https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report). -If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp). +If you prefer to submit without logging in, send email to +[secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your +message with our PGP key; please download it from the +[Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp). -You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). +You should receive a response within 24 hours. If for some reason you do not, +please follow up via email to ensure we received your original message. +Additional information can be found at +[microsoft.com/msrc](https://www.microsoft.com/msrc). -Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: +Please include the requested information listed below (as much as you can +provide) to help us better understand the nature and scope of the possible +issue: - * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) - * Full paths of source file(s) related to the manifestation of the issue - * The location of the affected source code (tag/branch/commit or direct URL) - * Any special configuration required to reproduce the issue - * Step-by-step instructions to reproduce the issue - * Proof-of-concept or exploit code (if possible) - * Impact of the issue, including how an attacker might exploit the issue +- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, + etc.) +- Full paths of source file(s) related to the manifestation of the issue +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- Step-by-step instructions to reproduce the issue +- Proof-of-concept or exploit code (if possible) +- Impact of the issue, including how an attacker might exploit the issue This information will help us triage your report more quickly. -If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs. +If you are reporting for a bug bounty, more complete reports can contribute to a +higher bounty award. Please visit our +[Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for +more details about our active programs. ## Preferred Languages @@ -36,6 +56,7 @@ We prefer all communications to be in English. ## Policy -Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd). +Microsoft follows the principle of +[Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd). diff --git a/SUPPORT.md b/SUPPORT.md index 291d4d4..6f3dce3 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -1,25 +1,32 @@ # TODO: The maintainer of this repo has not yet edited this file -**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? +**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this +product/project? -- **No CSS support:** Fill out this template with information about how to file issues and get help. -- **Yes CSS support:** Fill out an intake form at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work with/help you to determine next steps. -- **Not sure?** Fill out an intake as though the answer were "Yes". CSS will help you decide. +- **No CSS support:** Fill out this template with information about how to + file issues and get help. +- **Yes CSS support:** Fill out an intake form at + [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work + with/help you to determine next steps. +- **Not sure?** Fill out an intake as though the answer were "Yes". CSS will + help you decide. -*Then remove this first heading from this SUPPORT.MD file before publishing your repo.* +_Then remove this first heading from this SUPPORT.MD file before publishing your +repo._ # Support -## How to file issues and get help +## How to file issues and get help -This project uses GitHub Issues to track bugs and feature requests. Please search the existing -issues before filing new issues to avoid duplicates. For new issues, file your bug or -feature request as a new Issue. +This project uses GitHub Issues to track bugs and feature requests. Please +search the existing issues before filing new issues to avoid duplicates. For new +issues, file your bug or feature request as a new Issue. -For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE -FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER -CHANNEL. WHERE WILL YOU HELP PEOPLE?**. +For help and questions about using this project, please **REPO MAINTAINER: +INSERT INSTRUCTIONS HERE FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. +COULD BE A STACK OVERFLOW TAG OR OTHER CHANNEL. WHERE WILL YOU HELP PEOPLE?**. -## Microsoft Support Policy +## Microsoft Support Policy -Support for this **PROJECT or PRODUCT** is limited to the resources listed above. +Support for this **PROJECT or PRODUCT** is limited to the resources listed +above. diff --git a/flushdb.py b/flushdb.py index 65442ad..dd1da37 100644 --- a/flushdb.py +++ b/flushdb.py @@ -3,6 +3,7 @@ WARNING: This script will flush the entire Redis database. Use with caution. """ + import redis redis_client = redis.StrictRedis(host="0.0.0.0", port=6379, db=0, decode_responses=True) From afc8e0393807d8d4f8e6eb4f00e3475945e1f77b Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sun, 28 Jul 2024 14:09:30 +0300 Subject: [PATCH 35/43] --- LICENSE | 42 ++++---- README.md | 176 ++++++++++++++++----------------- SUPPORT.md | 64 ++++++------ main.py | 252 +++++++++++++++++++++++------------------------ models.py | 18 ++-- requirements.txt | 36 +++---- 6 files changed, 294 insertions(+), 294 deletions(-) diff --git a/LICENSE b/LICENSE index 62f454e..115963d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -MIT License - -Copyright (c) 2023 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +MIT License + +Copyright (c) 2023 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 11ca4bf..4fdcd81 100644 --- a/README.md +++ b/README.md @@ -1,88 +1,88 @@ -# Python/FastAPI Tutorial for Visual Studio Code - -This sample contains the completed program from the tutorial: -[FastAPI in Visual Studio Code](https://code.visualstudio.com/docs/python/tutorial-fastapi). -Immediate steps are not included. - -## Run the app using GitHub Codespaces - -[GitHub Codespaces](https://github.com/features/codespaces) provides -cloud-powered development environments that work how and where you want it to. -To learn how to set up a GitHub Codespace for this repository, check the -[documentation](https://docs.github.com/en/codespaces/developing-in-codespaces/creating-a-codespace-for-a-repository#creating-a-codespace-for-a-repository). - -Once you open this repository in GitHub Codespaces, you can press **F5** to -start the debugger and run the application. - -Once it's ready, you will see a notification with a button -`Open in the Browser`. Clicking the button will open your application on the -browser. You can then add `/docs` to the end of the URL to access the Swagger UI -and interact with the application! - -## Run the app locally in VS Code - -There are diffent ways you can run this app locally in VS Code depending on your -operating system. To get started, first clone this project on your machine and -then open it in VS Code (**File** > **Open Folder...**). - -### Windows - -To run this app locally in VS Code on Windows, you can use either -[WSL](https://learn.microsoft.com/en-us/windows/wsl/) (Windows Subsystem for -Linux) or [Docker](https://www.docker.com/products/docker-desktop). - -#### Docker Containers - -1. Make sure you have - [Docker installed](https://www.docker.com/products/docker-desktop) -1. Install the - [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) -1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and - run the "Dev Container: Reopen in Container" command. -1. Press **F5** to debug your application! - -#### WSL - -1. Make sure you have - [WSL installed](https://learn.microsoft.com/en-us/windows/wsl/) -1. Install the - [WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) - for VS Code -1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and - run the "WSL: Reopen Folder in WSL" command -1. Follow the remaining steps for [macOS/Linux](#macos--linux) below. - -### macOS / Linux - -1. Install the - [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) - for VS Code -1. Run the "Python: Create Environment" command in the Command Palette -1. Select `Venv`, the latest available version of Python and then the - `requirements.txt` file to install the dependencies. -1. Press **F5** to run your application! - -## Contributing - -Contributions to the sample are welcome! When submitting changes, also consider -submitting matching changes to the tutorial, the source file for which is -[tutorial-fastapi.md](https://github.com/Microsoft/vscode-docs/blob/master/docs/python/tutorial-fastapi.md). - -Most contributions require you to agree to a Contributor License Agreement (CLA) -declaring that you have the right to, and actually do, grant us the rights to -use your contribution. For details, visit https://cla.microsoft.com. - -When you submit a pull request, a CLA-bot automatically determines whether you -need to provide a CLA and decorate the PR appropriately (e.g., label, comment). -Simply follow the instructions provided by the bot. You will only need to do -this once across all repos using our CLA. - -## Additional details - -- This project has adopted the - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -- For more information see the - [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) - or -- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any - additional questions or comments. +# Python/FastAPI Tutorial for Visual Studio Code + +This sample contains the completed program from the tutorial: +[FastAPI in Visual Studio Code](https://code.visualstudio.com/docs/python/tutorial-fastapi). +Immediate steps are not included. + +## Run the app using GitHub Codespaces + +[GitHub Codespaces](https://github.com/features/codespaces) provides +cloud-powered development environments that work how and where you want it to. +To learn how to set up a GitHub Codespace for this repository, check the +[documentation](https://docs.github.com/en/codespaces/developing-in-codespaces/creating-a-codespace-for-a-repository#creating-a-codespace-for-a-repository). + +Once you open this repository in GitHub Codespaces, you can press **F5** to +start the debugger and run the application. + +Once it's ready, you will see a notification with a button +`Open in the Browser`. Clicking the button will open your application on the +browser. You can then add `/docs` to the end of the URL to access the Swagger UI +and interact with the application! + +## Run the app locally in VS Code + +There are diffent ways you can run this app locally in VS Code depending on your +operating system. To get started, first clone this project on your machine and +then open it in VS Code (**File** > **Open Folder...**). + +### Windows + +To run this app locally in VS Code on Windows, you can use either +[WSL](https://learn.microsoft.com/en-us/windows/wsl/) (Windows Subsystem for +Linux) or [Docker](https://www.docker.com/products/docker-desktop). + +#### Docker Containers + +1. Make sure you have + [Docker installed](https://www.docker.com/products/docker-desktop) +1. Install the + [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) +1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and + run the "Dev Container: Reopen in Container" command. +1. Press **F5** to debug your application! + +#### WSL + +1. Make sure you have + [WSL installed](https://learn.microsoft.com/en-us/windows/wsl/) +1. Install the + [WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) + for VS Code +1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and + run the "WSL: Reopen Folder in WSL" command +1. Follow the remaining steps for [macOS/Linux](#macos--linux) below. + +### macOS / Linux + +1. Install the + [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) + for VS Code +1. Run the "Python: Create Environment" command in the Command Palette +1. Select `Venv`, the latest available version of Python and then the + `requirements.txt` file to install the dependencies. +1. Press **F5** to run your application! + +## Contributing + +Contributions to the sample are welcome! When submitting changes, also consider +submitting matching changes to the tutorial, the source file for which is +[tutorial-fastapi.md](https://github.com/Microsoft/vscode-docs/blob/master/docs/python/tutorial-fastapi.md). + +Most contributions require you to agree to a Contributor License Agreement (CLA) +declaring that you have the right to, and actually do, grant us the rights to +use your contribution. For details, visit https://cla.microsoft.com. + +When you submit a pull request, a CLA-bot automatically determines whether you +need to provide a CLA and decorate the PR appropriately (e.g., label, comment). +Simply follow the instructions provided by the bot. You will only need to do +this once across all repos using our CLA. + +## Additional details + +- This project has adopted the + [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +- For more information see the + [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) + or +- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any + additional questions or comments. diff --git a/SUPPORT.md b/SUPPORT.md index 6f3dce3..4b5b614 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -1,32 +1,32 @@ -# TODO: The maintainer of this repo has not yet edited this file - -**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this -product/project? - -- **No CSS support:** Fill out this template with information about how to - file issues and get help. -- **Yes CSS support:** Fill out an intake form at - [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work - with/help you to determine next steps. -- **Not sure?** Fill out an intake as though the answer were "Yes". CSS will - help you decide. - -_Then remove this first heading from this SUPPORT.MD file before publishing your -repo._ - -# Support - -## How to file issues and get help - -This project uses GitHub Issues to track bugs and feature requests. Please -search the existing issues before filing new issues to avoid duplicates. For new -issues, file your bug or feature request as a new Issue. - -For help and questions about using this project, please **REPO MAINTAINER: -INSERT INSTRUCTIONS HERE FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. -COULD BE A STACK OVERFLOW TAG OR OTHER CHANNEL. WHERE WILL YOU HELP PEOPLE?**. - -## Microsoft Support Policy - -Support for this **PROJECT or PRODUCT** is limited to the resources listed -above. +# TODO: The maintainer of this repo has not yet edited this file + +**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this +product/project? + +- **No CSS support:** Fill out this template with information about how to + file issues and get help. +- **Yes CSS support:** Fill out an intake form at + [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work + with/help you to determine next steps. +- **Not sure?** Fill out an intake as though the answer were "Yes". CSS will + help you decide. + +_Then remove this first heading from this SUPPORT.MD file before publishing your +repo._ + +# Support + +## How to file issues and get help + +This project uses GitHub Issues to track bugs and feature requests. Please +search the existing issues before filing new issues to avoid duplicates. For new +issues, file your bug or feature request as a new Issue. + +For help and questions about using this project, please **REPO MAINTAINER: +INSERT INSTRUCTIONS HERE FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. +COULD BE A STACK OVERFLOW TAG OR OTHER CHANNEL. WHERE WILL YOU HELP PEOPLE?**. + +## Microsoft Support Policy + +Support for this **PROJECT or PRODUCT** is limited to the resources listed +above. diff --git a/main.py b/main.py index 1ad8072..3da3ace 100644 --- a/main.py +++ b/main.py @@ -1,126 +1,126 @@ -import os - -import redis -from fastapi import FastAPI, HTTPException, Request - -from models import ItemPayload - -app = FastAPI() - -redis_client = redis.StrictRedis(host="0.0.0.0", port=6379, db=0, decode_responses=True) - - -@app.get("/") -def home(request: Request) -> dict[str, str]: - url: str = ( - f"https://{os.getenv('CODESPACE_NAME')}-8000.{os.getenv('GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN')}/" - if os.getenv("CODESPACE_NAME") - else str(request.base_url) - ) - return { - "message": f"Navigate to the following URL to access the Swagger UI: {url}docs" - } - - -# Route to add an item -@app.post("/items/{item_name}/{quantity}") -def add_item(item_name: str, quantity: int) -> dict[str, ItemPayload]: - if quantity <= 0: - raise HTTPException(status_code=400, detail="Quantity must be greater than 0.") - - # Check if item already exists - item_id_str: str | None = redis_client.hget("item_name_to_id", item_name) - - if item_id_str is not None: - item_id = int(item_id_str) - quantity = redis_client.hincrby(f"item_id:{item_id}", "quantity", quantity) - else: - # Generate an id for the item - item_id: int = redis_client.incr("item_ids") - redis_client.hset( - f"item_id:{item_id}", - mapping={ - "item_id": item_id, - "item_name": item_name, - "quantity": quantity, - }, - ) - # Create a set so we can search by name too - redis_client.hset("item_name_to_id", item_name, item_id) - - return { - "item": ItemPayload(item_id=item_id, item_name=item_name, quantity=quantity) - } - - -# Route to list a specific item by id but using Redis -@app.get("/items/{item_id}") -def list_item(item_id: int) -> dict[str, dict[str, str]]: - if not redis_client.hexists(f"item_id:{item_id}", "item_id"): - raise HTTPException(status_code=404, detail="Item not found.") - else: - return {"item": redis_client.hgetall(f"item_id:{item_id}")} - - -@app.get("/items") -def list_items() -> dict[str, list[ItemPayload]]: - items: list[ItemPayload] = [] - stored_items: dict[str, str] = redis_client.hgetall("item_name_to_id") - - for name, id_str in stored_items.items(): - item_id: int = int(id_str) - - item_name_str: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") - if item_name_str is not None: - item_name: str = item_name_str - else: - continue # skip this item if it has no name - - item_quantity_str: str | None = redis_client.hget( - f"item_id:{item_id}", "quantity" - ) - if item_quantity_str is not None: - item_quantity: int = int(item_quantity_str) - else: - item_quantity = 0 - - items.append( - ItemPayload(item_id=item_id, item_name=item_name, quantity=item_quantity) - ) - - return {"items": items} - - -# Route to delete a specific item by id but using Redis -@app.delete("/items/{item_id}") -def delete_item(item_id: int) -> dict[str, str]: - if not redis_client.hexists(f"item_id:{item_id}", "item_id"): - raise HTTPException(status_code=404, detail="Item not found.") - else: - item_name: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") - redis_client.hdel("item_name_to_id", f"{item_name}") - redis_client.delete(f"item_id:{item_id}") - return {"result": "Item deleted."} - - -# Route to remove some quantity of a specific item by id but using Redis -@app.delete("/items/{item_id}/{quantity}") -def remove_quantity(item_id: int, quantity: int) -> dict[str, str]: - if not redis_client.hexists(f"item_id:{item_id}", "item_id"): - raise HTTPException(status_code=404, detail="Item not found.") - - item_quantity: str | None = redis_client.hget(f"item_id:{item_id}", "quantity") - - # if quantity to be removed is higher or equal to item's quantity, delete the item - if item_quantity is None: - existing_quantity: int = 0 - else: - existing_quantity: int = int(item_quantity) - if existing_quantity <= quantity: - item_name: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") - redis_client.hdel("item_name_to_id", f"{item_name}") - redis_client.delete(f"item_id:{item_id}") - return {"result": "Item deleted."} - else: - redis_client.hincrby(f"item_id:{item_id}", "quantity", -quantity) - return {"result": f"{quantity} items removed."} +import os + +import redis +from fastapi import FastAPI, HTTPException, Request + +from models import ItemPayload + +app = FastAPI() + +redis_client = redis.StrictRedis(host="0.0.0.0", port=6379, db=0, decode_responses=True) + + +@app.get("/") +def home(request: Request) -> dict[str, str]: + url: str = ( + f"https://{os.getenv('CODESPACE_NAME')}-8000.{os.getenv('GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN')}/" + if os.getenv("CODESPACE_NAME") + else str(request.base_url) + ) + return { + "message": f"Navigate to the following URL to access the Swagger UI: {url}docs" + } + + +# Route to add an item +@app.post("/items/{item_name}/{quantity}") +def add_item(item_name: str, quantity: int) -> dict[str, ItemPayload]: + if quantity <= 0: + raise HTTPException(status_code=400, detail="Quantity must be greater than 0.") + + # Check if item already exists + item_id_str: str | None = redis_client.hget("item_name_to_id", item_name) + + if item_id_str is not None: + item_id = int(item_id_str) + quantity = redis_client.hincrby(f"item_id:{item_id}", "quantity", quantity) + else: + # Generate an id for the item + item_id: int = redis_client.incr("item_ids") + redis_client.hset( + f"item_id:{item_id}", + mapping={ + "item_id": item_id, + "item_name": item_name, + "quantity": quantity, + }, + ) + # Create a set so we can search by name too + redis_client.hset("item_name_to_id", item_name, item_id) + + return { + "item": ItemPayload(item_id=item_id, item_name=item_name, quantity=quantity) + } + + +# Route to list a specific item by id but using Redis +@app.get("/items/{item_id}") +def list_item(item_id: int) -> dict[str, dict[str, str]]: + if not redis_client.hexists(f"item_id:{item_id}", "item_id"): + raise HTTPException(status_code=404, detail="Item not found.") + else: + return {"item": redis_client.hgetall(f"item_id:{item_id}")} + + +@app.get("/items") +def list_items() -> dict[str, list[ItemPayload]]: + items: list[ItemPayload] = [] + stored_items: dict[str, str] = redis_client.hgetall("item_name_to_id") + + for name, id_str in stored_items.items(): + item_id: int = int(id_str) + + item_name_str: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") + if item_name_str is not None: + item_name: str = item_name_str + else: + continue # skip this item if it has no name + + item_quantity_str: str | None = redis_client.hget( + f"item_id:{item_id}", "quantity" + ) + if item_quantity_str is not None: + item_quantity: int = int(item_quantity_str) + else: + item_quantity = 0 + + items.append( + ItemPayload(item_id=item_id, item_name=item_name, quantity=item_quantity) + ) + + return {"items": items} + + +# Route to delete a specific item by id but using Redis +@app.delete("/items/{item_id}") +def delete_item(item_id: int) -> dict[str, str]: + if not redis_client.hexists(f"item_id:{item_id}", "item_id"): + raise HTTPException(status_code=404, detail="Item not found.") + else: + item_name: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") + redis_client.hdel("item_name_to_id", f"{item_name}") + redis_client.delete(f"item_id:{item_id}") + return {"result": "Item deleted."} + + +# Route to remove some quantity of a specific item by id but using Redis +@app.delete("/items/{item_id}/{quantity}") +def remove_quantity(item_id: int, quantity: int) -> dict[str, str]: + if not redis_client.hexists(f"item_id:{item_id}", "item_id"): + raise HTTPException(status_code=404, detail="Item not found.") + + item_quantity: str | None = redis_client.hget(f"item_id:{item_id}", "quantity") + + # if quantity to be removed is higher or equal to item's quantity, delete the item + if item_quantity is None: + existing_quantity: int = 0 + else: + existing_quantity: int = int(item_quantity) + if existing_quantity <= quantity: + item_name: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") + redis_client.hdel("item_name_to_id", f"{item_name}") + redis_client.delete(f"item_id:{item_id}") + return {"result": "Item deleted."} + else: + redis_client.hincrby(f"item_id:{item_id}", "quantity", -quantity) + return {"result": f"{quantity} items removed."} diff --git a/models.py b/models.py index bba7954..6d6a40c 100644 --- a/models.py +++ b/models.py @@ -1,9 +1,9 @@ -from typing import Optional - -from pydantic import BaseModel - - -class ItemPayload(BaseModel): - item_id: Optional[int] - item_name: str - quantity: int +from typing import Optional + +from pydantic import BaseModel + + +class ItemPayload(BaseModel): + item_id: Optional[int] + item_name: str + quantity: int diff --git a/requirements.txt b/requirements.txt index 6ea752e..7631c08 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,18 @@ -annotated-types==0.6.0 -anyio==3.7.1 -cffi==1.16.0 -click==8.1.7 -cryptography==41.0.4 -fastapi==0.104.0 -h11==0.14.0 -idna==3.4 -pycparser==2.21 -pydantic==2.4.2 -pydantic-core==2.10.1 -redis==5.0.1 -sniffio==1.3.0 -starlette==0.27.0 -types-pyopenssl==23.3.0.0 -types-redis==4.6.0.7 -typing-extensions==4.8.0 -uvicorn==0.23.2 +annotated-types==0.6.0 +anyio==3.7.1 +cffi==1.16.0 +click==8.1.7 +cryptography==41.0.4 +fastapi==0.104.0 +h11==0.14.0 +idna==3.4 +pycparser==2.21 +pydantic==2.4.2 +pydantic-core==2.10.1 +redis==5.0.1 +sniffio==1.3.0 +starlette==0.27.0 +types-pyopenssl==23.3.0.0 +types-redis==4.6.0.7 +typing-extensions==4.8.0 +uvicorn==0.23.2 From abdcf681a448a6c77b0ef437998461b0ba42d593 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Thu, 22 Aug 2024 03:02:15 +0300 Subject: [PATCH 36/43] --- .github/dependabot.yml | 14 ++++++++ .github/workflows/Dependabot.yml | 45 +++++++++++++++++++++++++ .github/workflows/GitHub.yml | 58 ++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/Dependabot.yml create mode 100644 .github/workflows/GitHub.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4242a05 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +enable-beta-ecosystems: true + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" + versioning-strategy: increase diff --git a/.github/workflows/Dependabot.yml b/.github/workflows/Dependabot.yml new file mode 100644 index 0000000..387fece --- /dev/null +++ b/.github/workflows/Dependabot.yml @@ -0,0 +1,45 @@ +name: Dependabot + +concurrency: + group: Dependabot-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + security-events: write + contents: write + pull-requests: write + +on: + workflow_dispatch: + pull_request: + +jobs: + Approve: + runs-on: ubuntu-latest + + if: ${{ github.actor == 'dependabot[bot]' }} + + steps: + - uses: dependabot/fetch-metadata@v2.2.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + Merge: + runs-on: ubuntu-latest + + if: ${{ github.actor == 'dependabot[bot]' }} + + steps: + - uses: dependabot/fetch-metadata@v2.2.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/GitHub.yml b/.github/workflows/GitHub.yml new file mode 100644 index 0000000..7b1e399 --- /dev/null +++ b/.github/workflows/GitHub.yml @@ -0,0 +1,58 @@ +name: GitHub + +concurrency: + group: GitHub-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + issues: write + pull-requests: write + +on: + issues: + types: [opened] + pull_request: + types: [opened] + +jobs: + Assign: + runs-on: ubuntu-latest + + env: + ADBLOCK: true + ASTRO_TELEMETRY_DISABLED: 1 + AUTOMATEDLAB_TELEMETRY_OPTOUT: 1 + AZURE_CORE_COLLECT_TELEMETRY: 0 + CHOOSENIM_NO_ANALYTICS: 1 + DIEZ_DO_NOT_TRACK: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT: 1 + DO_NOT_TRACK: 1 + ET_NO_TELEMETRY: 1 + GATSBY_TELEMETRY_DISABLED: 1 + GATSBY_TELEMETRY_OPTOUT: 1 + GATSBY_TELEMETRY_OPT_OUT: 1 + GRIT_TELEMETRY_DISABLED: 1 + HASURA_GRAPHQL_ENABLE_TELEMETRY: false + HINT_TELEMETRY: off + HOMEBREW_NO_ANALYTICS: 1 + INFLUXD_REPORTING_DISABLED: true + ITERATIVE_DO_NOT_TRACK: 1 + NEXT_TELEMETRY_DEBUG: 1 + NEXT_TELEMETRY_DISABLED: 1 + NG_CLI_ANALYTICS: false + NUXT_TELEMETRY_DISABLED: 1 + PIN_DO_NOT_TRACK: 1 + POWERSHELL_TELEMETRY_OPTOUT: 1 + SAM_CLI_TELEMETRY: 0 + STNOUPGRADE: 1 + STRIPE_CLI_TELEMETRY_OPTOUT: 1 + TELEMETRY_DISABLED: 1 + TERRAFORM_TELEMETRY: 0 + + steps: + - uses: pozil/auto-assign-issue@v2.0.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + assignees: NikolaRHristov + numOfAssignee: 1 From 69eec4e9668c6a8b36f3c002faa673b643ce58fe Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sat, 24 Aug 2024 10:23:24 +0300 Subject: [PATCH 37/43] --- .devcontainer/devcontainer.json | 31 ------------------------ .github/dependabot.yml | 6 ----- .github/workflows/test-application.yml | 33 -------------------------- .vscode/launch.json | 19 --------------- 4 files changed, 89 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/test-application.yml delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index ee3d10a..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,6 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "pip" - directory: "/" # Location of package manifests - schedule: - interval: "weekly" diff --git a/.github/workflows/test-application.yml b/.github/workflows/test-application.yml deleted file mode 100644 index 0b99df1..0000000 --- a/.github/workflows/test-application.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Test Application - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - env: - PORT: 8000 - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Start the app - run: uvicorn main:app --host 0.0.0.0 --port ${{ env.PORT }} & - - - name: Sleep for 1 minute - run: sleep 60 - - - name: Stop the app - run: pkill -f 'uvicorn main:app' - diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From 3e307f6e0108533fc686ae6f4220baa715a42a87 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sun, 25 Aug 2024 01:51:30 +0300 Subject: [PATCH 38/43] --- .github/dependabot.yml | 14 -------- .github/workflows/Dependabot.yml | 45 ------------------------- .github/workflows/GitHub.yml | 58 -------------------------------- 3 files changed, 117 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/Dependabot.yml delete mode 100644 .github/workflows/GitHub.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 4242a05..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: 2 -enable-beta-ecosystems: true - -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" - - - package-ecosystem: "pip" - directory: "/" - schedule: - interval: "daily" - versioning-strategy: increase diff --git a/.github/workflows/Dependabot.yml b/.github/workflows/Dependabot.yml deleted file mode 100644 index 387fece..0000000 --- a/.github/workflows/Dependabot.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Dependabot - -concurrency: - group: Dependabot-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - security-events: write - contents: write - pull-requests: write - -on: - workflow_dispatch: - pull_request: - -jobs: - Approve: - runs-on: ubuntu-latest - - if: ${{ github.actor == 'dependabot[bot]' }} - - steps: - - uses: dependabot/fetch-metadata@v2.2.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - run: gh pr review --approve "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - Merge: - runs-on: ubuntu-latest - - if: ${{ github.actor == 'dependabot[bot]' }} - - steps: - - uses: dependabot/fetch-metadata@v2.2.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - run: gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/GitHub.yml b/.github/workflows/GitHub.yml deleted file mode 100644 index 7b1e399..0000000 --- a/.github/workflows/GitHub.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: GitHub - -concurrency: - group: GitHub-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - issues: write - pull-requests: write - -on: - issues: - types: [opened] - pull_request: - types: [opened] - -jobs: - Assign: - runs-on: ubuntu-latest - - env: - ADBLOCK: true - ASTRO_TELEMETRY_DISABLED: 1 - AUTOMATEDLAB_TELEMETRY_OPTOUT: 1 - AZURE_CORE_COLLECT_TELEMETRY: 0 - CHOOSENIM_NO_ANALYTICS: 1 - DIEZ_DO_NOT_TRACK: 1 - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT: 1 - DO_NOT_TRACK: 1 - ET_NO_TELEMETRY: 1 - GATSBY_TELEMETRY_DISABLED: 1 - GATSBY_TELEMETRY_OPTOUT: 1 - GATSBY_TELEMETRY_OPT_OUT: 1 - GRIT_TELEMETRY_DISABLED: 1 - HASURA_GRAPHQL_ENABLE_TELEMETRY: false - HINT_TELEMETRY: off - HOMEBREW_NO_ANALYTICS: 1 - INFLUXD_REPORTING_DISABLED: true - ITERATIVE_DO_NOT_TRACK: 1 - NEXT_TELEMETRY_DEBUG: 1 - NEXT_TELEMETRY_DISABLED: 1 - NG_CLI_ANALYTICS: false - NUXT_TELEMETRY_DISABLED: 1 - PIN_DO_NOT_TRACK: 1 - POWERSHELL_TELEMETRY_OPTOUT: 1 - SAM_CLI_TELEMETRY: 0 - STNOUPGRADE: 1 - STRIPE_CLI_TELEMETRY_OPTOUT: 1 - TELEMETRY_DISABLED: 1 - TERRAFORM_TELEMETRY: 0 - - steps: - - uses: pozil/auto-assign-issue@v2.0.0 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - assignees: NikolaRHristov - numOfAssignee: 1 From 1e39f230745105cc1c226f2f8314ee2ec4fec538 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Tue, 27 Aug 2024 11:22:50 +0300 Subject: [PATCH 39/43] --- .github/dependabot.yml | 14 ++++++++ .github/workflows/Dependabot.yml | 45 +++++++++++++++++++++++++ .github/workflows/GitHub.yml | 58 ++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/Dependabot.yml create mode 100644 .github/workflows/GitHub.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4242a05 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +enable-beta-ecosystems: true + +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" + versioning-strategy: increase diff --git a/.github/workflows/Dependabot.yml b/.github/workflows/Dependabot.yml new file mode 100644 index 0000000..387fece --- /dev/null +++ b/.github/workflows/Dependabot.yml @@ -0,0 +1,45 @@ +name: Dependabot + +concurrency: + group: Dependabot-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + security-events: write + contents: write + pull-requests: write + +on: + workflow_dispatch: + pull_request: + +jobs: + Approve: + runs-on: ubuntu-latest + + if: ${{ github.actor == 'dependabot[bot]' }} + + steps: + - uses: dependabot/fetch-metadata@v2.2.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + Merge: + runs-on: ubuntu-latest + + if: ${{ github.actor == 'dependabot[bot]' }} + + steps: + - uses: dependabot/fetch-metadata@v2.2.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/GitHub.yml b/.github/workflows/GitHub.yml new file mode 100644 index 0000000..7b1e399 --- /dev/null +++ b/.github/workflows/GitHub.yml @@ -0,0 +1,58 @@ +name: GitHub + +concurrency: + group: GitHub-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + issues: write + pull-requests: write + +on: + issues: + types: [opened] + pull_request: + types: [opened] + +jobs: + Assign: + runs-on: ubuntu-latest + + env: + ADBLOCK: true + ASTRO_TELEMETRY_DISABLED: 1 + AUTOMATEDLAB_TELEMETRY_OPTOUT: 1 + AZURE_CORE_COLLECT_TELEMETRY: 0 + CHOOSENIM_NO_ANALYTICS: 1 + DIEZ_DO_NOT_TRACK: 1 + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT: 1 + DO_NOT_TRACK: 1 + ET_NO_TELEMETRY: 1 + GATSBY_TELEMETRY_DISABLED: 1 + GATSBY_TELEMETRY_OPTOUT: 1 + GATSBY_TELEMETRY_OPT_OUT: 1 + GRIT_TELEMETRY_DISABLED: 1 + HASURA_GRAPHQL_ENABLE_TELEMETRY: false + HINT_TELEMETRY: off + HOMEBREW_NO_ANALYTICS: 1 + INFLUXD_REPORTING_DISABLED: true + ITERATIVE_DO_NOT_TRACK: 1 + NEXT_TELEMETRY_DEBUG: 1 + NEXT_TELEMETRY_DISABLED: 1 + NG_CLI_ANALYTICS: false + NUXT_TELEMETRY_DISABLED: 1 + PIN_DO_NOT_TRACK: 1 + POWERSHELL_TELEMETRY_OPTOUT: 1 + SAM_CLI_TELEMETRY: 0 + STNOUPGRADE: 1 + STRIPE_CLI_TELEMETRY_OPTOUT: 1 + TELEMETRY_DISABLED: 1 + TERRAFORM_TELEMETRY: 0 + + steps: + - uses: pozil/auto-assign-issue@v2.0.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + assignees: NikolaRHristov + numOfAssignee: 1 From 623637574160eaeede0124e22ffccd28a5697c4b Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Wed, 28 Aug 2024 09:26:41 +0300 Subject: [PATCH 40/43] --- .github/dependabot.yml | 14 -------- .github/workflows/Dependabot.yml | 45 ------------------------- .github/workflows/GitHub.yml | 58 -------------------------------- 3 files changed, 117 deletions(-) delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/Dependabot.yml delete mode 100644 .github/workflows/GitHub.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 4242a05..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: 2 -enable-beta-ecosystems: true - -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" - - - package-ecosystem: "pip" - directory: "/" - schedule: - interval: "daily" - versioning-strategy: increase diff --git a/.github/workflows/Dependabot.yml b/.github/workflows/Dependabot.yml deleted file mode 100644 index 387fece..0000000 --- a/.github/workflows/Dependabot.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Dependabot - -concurrency: - group: Dependabot-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - security-events: write - contents: write - pull-requests: write - -on: - workflow_dispatch: - pull_request: - -jobs: - Approve: - runs-on: ubuntu-latest - - if: ${{ github.actor == 'dependabot[bot]' }} - - steps: - - uses: dependabot/fetch-metadata@v2.2.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - run: gh pr review --approve "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - Merge: - runs-on: ubuntu-latest - - if: ${{ github.actor == 'dependabot[bot]' }} - - steps: - - uses: dependabot/fetch-metadata@v2.2.0 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - - run: gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/GitHub.yml b/.github/workflows/GitHub.yml deleted file mode 100644 index 7b1e399..0000000 --- a/.github/workflows/GitHub.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: GitHub - -concurrency: - group: GitHub-${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - issues: write - pull-requests: write - -on: - issues: - types: [opened] - pull_request: - types: [opened] - -jobs: - Assign: - runs-on: ubuntu-latest - - env: - ADBLOCK: true - ASTRO_TELEMETRY_DISABLED: 1 - AUTOMATEDLAB_TELEMETRY_OPTOUT: 1 - AZURE_CORE_COLLECT_TELEMETRY: 0 - CHOOSENIM_NO_ANALYTICS: 1 - DIEZ_DO_NOT_TRACK: 1 - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT: 1 - DO_NOT_TRACK: 1 - ET_NO_TELEMETRY: 1 - GATSBY_TELEMETRY_DISABLED: 1 - GATSBY_TELEMETRY_OPTOUT: 1 - GATSBY_TELEMETRY_OPT_OUT: 1 - GRIT_TELEMETRY_DISABLED: 1 - HASURA_GRAPHQL_ENABLE_TELEMETRY: false - HINT_TELEMETRY: off - HOMEBREW_NO_ANALYTICS: 1 - INFLUXD_REPORTING_DISABLED: true - ITERATIVE_DO_NOT_TRACK: 1 - NEXT_TELEMETRY_DEBUG: 1 - NEXT_TELEMETRY_DISABLED: 1 - NG_CLI_ANALYTICS: false - NUXT_TELEMETRY_DISABLED: 1 - PIN_DO_NOT_TRACK: 1 - POWERSHELL_TELEMETRY_OPTOUT: 1 - SAM_CLI_TELEMETRY: 0 - STNOUPGRADE: 1 - STRIPE_CLI_TELEMETRY_OPTOUT: 1 - TELEMETRY_DISABLED: 1 - TERRAFORM_TELEMETRY: 0 - - steps: - - uses: pozil/auto-assign-issue@v2.0.0 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - assignees: NikolaRHristov - numOfAssignee: 1 From f4734575184c927230950886cf5de008db3cad1e Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Fri, 30 Aug 2024 09:53:45 +0300 Subject: [PATCH 41/43] --- .gitignore | 106 -------------------------------------- CODE_OF_CONDUCT.md | 11 ---- LICENSE | 21 -------- README.md | 88 ------------------------------- SECURITY.md | 62 ---------------------- SUPPORT.md | 32 ------------ flushdb.py | 10 ---- main.py | 126 --------------------------------------------- models.py | 9 ---- requirements.txt | 18 ------- 10 files changed, 483 deletions(-) delete mode 100644 .gitignore delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 LICENSE delete mode 100644 README.md delete mode 100644 SECURITY.md delete mode 100644 SUPPORT.md delete mode 100644 flushdb.py delete mode 100644 main.py delete mode 100644 models.py delete mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore deleted file mode 100644 index f75400b..0000000 --- a/.gitignore +++ /dev/null @@ -1,106 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ - -settings.json \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index bb1fb9a..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,11 +0,0 @@ -# Microsoft Open Source Code of Conduct - -This project has adopted the -[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). - -Resources: - -- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) -- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) -- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with - questions or concerns diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 115963d..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md deleted file mode 100644 index 4fdcd81..0000000 --- a/README.md +++ /dev/null @@ -1,88 +0,0 @@ -# Python/FastAPI Tutorial for Visual Studio Code - -This sample contains the completed program from the tutorial: -[FastAPI in Visual Studio Code](https://code.visualstudio.com/docs/python/tutorial-fastapi). -Immediate steps are not included. - -## Run the app using GitHub Codespaces - -[GitHub Codespaces](https://github.com/features/codespaces) provides -cloud-powered development environments that work how and where you want it to. -To learn how to set up a GitHub Codespace for this repository, check the -[documentation](https://docs.github.com/en/codespaces/developing-in-codespaces/creating-a-codespace-for-a-repository#creating-a-codespace-for-a-repository). - -Once you open this repository in GitHub Codespaces, you can press **F5** to -start the debugger and run the application. - -Once it's ready, you will see a notification with a button -`Open in the Browser`. Clicking the button will open your application on the -browser. You can then add `/docs` to the end of the URL to access the Swagger UI -and interact with the application! - -## Run the app locally in VS Code - -There are diffent ways you can run this app locally in VS Code depending on your -operating system. To get started, first clone this project on your machine and -then open it in VS Code (**File** > **Open Folder...**). - -### Windows - -To run this app locally in VS Code on Windows, you can use either -[WSL](https://learn.microsoft.com/en-us/windows/wsl/) (Windows Subsystem for -Linux) or [Docker](https://www.docker.com/products/docker-desktop). - -#### Docker Containers - -1. Make sure you have - [Docker installed](https://www.docker.com/products/docker-desktop) -1. Install the - [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) -1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and - run the "Dev Container: Reopen in Container" command. -1. Press **F5** to debug your application! - -#### WSL - -1. Make sure you have - [WSL installed](https://learn.microsoft.com/en-us/windows/wsl/) -1. Install the - [WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) - for VS Code -1. Open the Command Palette in VS Code (**View** > **Command Palette...**) and - run the "WSL: Reopen Folder in WSL" command -1. Follow the remaining steps for [macOS/Linux](#macos--linux) below. - -### macOS / Linux - -1. Install the - [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) - for VS Code -1. Run the "Python: Create Environment" command in the Command Palette -1. Select `Venv`, the latest available version of Python and then the - `requirements.txt` file to install the dependencies. -1. Press **F5** to run your application! - -## Contributing - -Contributions to the sample are welcome! When submitting changes, also consider -submitting matching changes to the tutorial, the source file for which is -[tutorial-fastapi.md](https://github.com/Microsoft/vscode-docs/blob/master/docs/python/tutorial-fastapi.md). - -Most contributions require you to agree to a Contributor License Agreement (CLA) -declaring that you have the right to, and actually do, grant us the rights to -use your contribution. For details, visit https://cla.microsoft.com. - -When you submit a pull request, a CLA-bot automatically determines whether you -need to provide a CLA and decorate the PR appropriately (e.g., label, comment). -Simply follow the instructions provided by the bot. You will only need to do -this once across all repos using our CLA. - -## Additional details - -- This project has adopted the - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -- For more information see the - [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) - or -- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any - additional questions or comments. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 27d107b..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,62 +0,0 @@ - - -## Security - -Microsoft takes the security of our software products and services seriously, -which includes all source code repositories managed through our GitHub -organizations, which include [Microsoft](https://github.com/Microsoft), -[Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), -[AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin). - -If you believe you have found a security vulnerability in any Microsoft-owned -repository that meets -[Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), -please report it to us as described below. - -## Reporting Security Issues - -**Please do not report security vulnerabilities through public GitHub issues.** - -Instead, please report them to the Microsoft Security Response Center (MSRC) at -[https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report). - -If you prefer to submit without logging in, send email to -[secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your -message with our PGP key; please download it from the -[Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp). - -You should receive a response within 24 hours. If for some reason you do not, -please follow up via email to ensure we received your original message. -Additional information can be found at -[microsoft.com/msrc](https://www.microsoft.com/msrc). - -Please include the requested information listed below (as much as you can -provide) to help us better understand the nature and scope of the possible -issue: - -- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, - etc.) -- Full paths of source file(s) related to the manifestation of the issue -- The location of the affected source code (tag/branch/commit or direct URL) -- Any special configuration required to reproduce the issue -- Step-by-step instructions to reproduce the issue -- Proof-of-concept or exploit code (if possible) -- Impact of the issue, including how an attacker might exploit the issue - -This information will help us triage your report more quickly. - -If you are reporting for a bug bounty, more complete reports can contribute to a -higher bounty award. Please visit our -[Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for -more details about our active programs. - -## Preferred Languages - -We prefer all communications to be in English. - -## Policy - -Microsoft follows the principle of -[Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd). - - diff --git a/SUPPORT.md b/SUPPORT.md deleted file mode 100644 index 4b5b614..0000000 --- a/SUPPORT.md +++ /dev/null @@ -1,32 +0,0 @@ -# TODO: The maintainer of this repo has not yet edited this file - -**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this -product/project? - -- **No CSS support:** Fill out this template with information about how to - file issues and get help. -- **Yes CSS support:** Fill out an intake form at - [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work - with/help you to determine next steps. -- **Not sure?** Fill out an intake as though the answer were "Yes". CSS will - help you decide. - -_Then remove this first heading from this SUPPORT.MD file before publishing your -repo._ - -# Support - -## How to file issues and get help - -This project uses GitHub Issues to track bugs and feature requests. Please -search the existing issues before filing new issues to avoid duplicates. For new -issues, file your bug or feature request as a new Issue. - -For help and questions about using this project, please **REPO MAINTAINER: -INSERT INSTRUCTIONS HERE FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. -COULD BE A STACK OVERFLOW TAG OR OTHER CHANNEL. WHERE WILL YOU HELP PEOPLE?**. - -## Microsoft Support Policy - -Support for this **PROJECT or PRODUCT** is limited to the resources listed -above. diff --git a/flushdb.py b/flushdb.py deleted file mode 100644 index dd1da37..0000000 --- a/flushdb.py +++ /dev/null @@ -1,10 +0,0 @@ -""" -This module is used to interact with a Redis database. - -WARNING: This script will flush the entire Redis database. Use with caution. -""" - -import redis - -redis_client = redis.StrictRedis(host="0.0.0.0", port=6379, db=0, decode_responses=True) -redis_client.flushdb() diff --git a/main.py b/main.py deleted file mode 100644 index 3da3ace..0000000 --- a/main.py +++ /dev/null @@ -1,126 +0,0 @@ -import os - -import redis -from fastapi import FastAPI, HTTPException, Request - -from models import ItemPayload - -app = FastAPI() - -redis_client = redis.StrictRedis(host="0.0.0.0", port=6379, db=0, decode_responses=True) - - -@app.get("/") -def home(request: Request) -> dict[str, str]: - url: str = ( - f"https://{os.getenv('CODESPACE_NAME')}-8000.{os.getenv('GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN')}/" - if os.getenv("CODESPACE_NAME") - else str(request.base_url) - ) - return { - "message": f"Navigate to the following URL to access the Swagger UI: {url}docs" - } - - -# Route to add an item -@app.post("/items/{item_name}/{quantity}") -def add_item(item_name: str, quantity: int) -> dict[str, ItemPayload]: - if quantity <= 0: - raise HTTPException(status_code=400, detail="Quantity must be greater than 0.") - - # Check if item already exists - item_id_str: str | None = redis_client.hget("item_name_to_id", item_name) - - if item_id_str is not None: - item_id = int(item_id_str) - quantity = redis_client.hincrby(f"item_id:{item_id}", "quantity", quantity) - else: - # Generate an id for the item - item_id: int = redis_client.incr("item_ids") - redis_client.hset( - f"item_id:{item_id}", - mapping={ - "item_id": item_id, - "item_name": item_name, - "quantity": quantity, - }, - ) - # Create a set so we can search by name too - redis_client.hset("item_name_to_id", item_name, item_id) - - return { - "item": ItemPayload(item_id=item_id, item_name=item_name, quantity=quantity) - } - - -# Route to list a specific item by id but using Redis -@app.get("/items/{item_id}") -def list_item(item_id: int) -> dict[str, dict[str, str]]: - if not redis_client.hexists(f"item_id:{item_id}", "item_id"): - raise HTTPException(status_code=404, detail="Item not found.") - else: - return {"item": redis_client.hgetall(f"item_id:{item_id}")} - - -@app.get("/items") -def list_items() -> dict[str, list[ItemPayload]]: - items: list[ItemPayload] = [] - stored_items: dict[str, str] = redis_client.hgetall("item_name_to_id") - - for name, id_str in stored_items.items(): - item_id: int = int(id_str) - - item_name_str: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") - if item_name_str is not None: - item_name: str = item_name_str - else: - continue # skip this item if it has no name - - item_quantity_str: str | None = redis_client.hget( - f"item_id:{item_id}", "quantity" - ) - if item_quantity_str is not None: - item_quantity: int = int(item_quantity_str) - else: - item_quantity = 0 - - items.append( - ItemPayload(item_id=item_id, item_name=item_name, quantity=item_quantity) - ) - - return {"items": items} - - -# Route to delete a specific item by id but using Redis -@app.delete("/items/{item_id}") -def delete_item(item_id: int) -> dict[str, str]: - if not redis_client.hexists(f"item_id:{item_id}", "item_id"): - raise HTTPException(status_code=404, detail="Item not found.") - else: - item_name: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") - redis_client.hdel("item_name_to_id", f"{item_name}") - redis_client.delete(f"item_id:{item_id}") - return {"result": "Item deleted."} - - -# Route to remove some quantity of a specific item by id but using Redis -@app.delete("/items/{item_id}/{quantity}") -def remove_quantity(item_id: int, quantity: int) -> dict[str, str]: - if not redis_client.hexists(f"item_id:{item_id}", "item_id"): - raise HTTPException(status_code=404, detail="Item not found.") - - item_quantity: str | None = redis_client.hget(f"item_id:{item_id}", "quantity") - - # if quantity to be removed is higher or equal to item's quantity, delete the item - if item_quantity is None: - existing_quantity: int = 0 - else: - existing_quantity: int = int(item_quantity) - if existing_quantity <= quantity: - item_name: str | None = redis_client.hget(f"item_id:{item_id}", "item_name") - redis_client.hdel("item_name_to_id", f"{item_name}") - redis_client.delete(f"item_id:{item_id}") - return {"result": "Item deleted."} - else: - redis_client.hincrby(f"item_id:{item_id}", "quantity", -quantity) - return {"result": f"{quantity} items removed."} diff --git a/models.py b/models.py deleted file mode 100644 index 6d6a40c..0000000 --- a/models.py +++ /dev/null @@ -1,9 +0,0 @@ -from typing import Optional - -from pydantic import BaseModel - - -class ItemPayload(BaseModel): - item_id: Optional[int] - item_name: str - quantity: int diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 7631c08..0000000 --- a/requirements.txt +++ /dev/null @@ -1,18 +0,0 @@ -annotated-types==0.6.0 -anyio==3.7.1 -cffi==1.16.0 -click==8.1.7 -cryptography==41.0.4 -fastapi==0.104.0 -h11==0.14.0 -idna==3.4 -pycparser==2.21 -pydantic==2.4.2 -pydantic-core==2.10.1 -redis==5.0.1 -sniffio==1.3.0 -starlette==0.27.0 -types-pyopenssl==23.3.0.0 -types-redis==4.6.0.7 -typing-extensions==4.8.0 -uvicorn==0.23.2 From d6dc46d86736ddfc20f0d9ee420fa3cdb2d151ab Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Tue, 10 Sep 2024 03:21:17 +0300 Subject: [PATCH 42/43] --- .devcontainer/devcontainer.json | 31 ------------------------ .github/dependabot.yml | 6 ----- .github/workflows/test-application.yml | 33 -------------------------- .vscode/launch.json | 19 --------------- 4 files changed, 89 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/test-application.yml delete mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index dd7a996..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/python -{ - "name": "Python 3", - // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", - "features": { - "ghcr.io/itsmechlark/features/redis-server:1": {} - }, - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip3 install --user -r requirements.txt", - // Configure tool-specific properties. - "customizations": { - "vscode": { - "extensions": [ - "ms-python.python", - "ms-python.vscode-pylance", - "esbenp.prettier-vscode", - "ms-python.black-formatter", - "charliermarsh.ruff", - "ms-python.debugpy" - ] - } - } - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index ee3d10a..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,6 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "pip" - directory: "/" # Location of package manifests - schedule: - interval: "weekly" diff --git a/.github/workflows/test-application.yml b/.github/workflows/test-application.yml deleted file mode 100644 index 0b99df1..0000000 --- a/.github/workflows/test-application.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Test Application - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - env: - PORT: 8000 - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Start the app - run: uvicorn main:app --host 0.0.0.0 --port ${{ env.PORT }} & - - - name: Sleep for 1 minute - run: sleep 60 - - - name: Stop the app - run: pkill -f 'uvicorn main:app' - diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c5bd5d0..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Python Debugger: FastAPI", - "type": "debugpy", - "request": "launch", - "module": "uvicorn", - "args": [ - "main:app", - "--reload" - ], - "jinja": true - } - ] -} \ No newline at end of file From b8809ff4f0590f726dc1416e89f0b3af257d4c55 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Sep 2024 00:50:36 +0000 Subject: [PATCH 43/43] Bump cryptography from 41.0.4 to 43.0.1 Bumps [cryptography](https://github.com/pyca/cryptography) from 41.0.4 to 43.0.1. - [Changelog](https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pyca/cryptography/compare/41.0.4...43.0.1) --- updated-dependencies: - dependency-name: cryptography dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 6ea752e..2799c4d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ annotated-types==0.6.0 anyio==3.7.1 cffi==1.16.0 click==8.1.7 -cryptography==41.0.4 +cryptography==43.0.1 fastapi==0.104.0 h11==0.14.0 idna==3.4