Backend logic implementation for realworld with awesome FastAPI

Overview

./.github/assets/logo.png


Quickstart

First, run PostgreSQL, set environment variables and create database. For example using docker:

export POSTGRES_DB=rwdb POSTGRES_PORT=5432 POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres
docker run --name pgdb --rm -e POSTGRES_USER="$POSTGRES_USER" -e POSTGRES_PASSWORD="$POSTGRES_PASSWORD" -e POSTGRES_DB="$POSTGRES_DB" postgres
export POSTGRES_HOST=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pgdb)
createdb --host=$POSTGRES_HOST --port=$POSTGRES_PORT --username=$POSTGRES_USER $POSTGRES_DB

Then run the following commands to bootstrap your environment with poetry:

git clone https://github.com/nsidnev/fastapi-realworld-example-app
cd fastapi-realworld-example-app
poetry install
poetry shell

Then create .env file (or rename and modify .env.example) in project root and set environment variables for application:

touch .env
echo DB_CONNECTION=postgresql://$POSTGRES_USER:[email protected]$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB >> .env
echo SECRET_KEY=$(openssl rand -hex 32) >> .env

To run the web application in debug use:

alembic upgrade head
uvicorn app.main:app --reload

Run tests

Tests for this project are defined in the tests/ folder.

This project uses pytest to define tests because it allows you to use the assert keyword with good formatting for failed assertations.

To run all the tests of a project, simply run the pytest command:

$ pytest
================================================= test session starts ==================================================
platform linux -- Python 3.8.3, pytest-5.4.2, py-1.8.1, pluggy-0.13.1
rootdir: /home/some-user/user-projects/fastapi-realworld-example-app, inifile: setup.cfg, testpaths: tests
plugins: env-0.6.2, cov-2.9.0, asyncio-0.12.0
collected 90 items

tests/test_api/test_errors/test_422_error.py .                                                                   [  1%]
tests/test_api/test_errors/test_error.py .                                                                       [  2%]
tests/test_api/test_routes/test_articles.py .................................                                    [ 38%]
tests/test_api/test_routes/test_authentication.py ..                                                             [ 41%]
tests/test_api/test_routes/test_comments.py ....                                                                 [ 45%]
tests/test_api/test_routes/test_login.py ...                                                                     [ 48%]
tests/test_api/test_routes/test_profiles.py ............                                                         [ 62%]
tests/test_api/test_routes/test_registration.py ...                                                              [ 65%]
tests/test_api/test_routes/test_tags.py ..                                                                       [ 67%]
tests/test_api/test_routes/test_users.py ....................                                                    [ 90%]
tests/test_db/test_queries/test_tables.py ...                                                                    [ 93%]
tests/test_schemas/test_rw_model.py .                                                                            [ 94%]
tests/test_services/test_jwt.py .....                                                                            [100%]

============================================ 90 passed in 70.50s (0:01:10) =============================================
$

This project does not use your local PostgreSQL by default, but creates it in docker as a container (you can see it if you type docker ps when the tests are executed, the docker container for PostgreSQL should be launched with with a name like test-postgres-725b4bd4-04f5-4c59-9870-af747d3b182f). But there are cases when you don't want to use docker for tests as a database provider (which takes an additional +- 5-10 seconds for its bootstrap before executing the tests), for example, in CI, or if you have problems with the docker driver or for any other reason. In this case, you can run the tests using your already running database with the following command:

$ USE_LOCAL_DB_FOR_TEST=True pytest

Which will use your local database with DSN from the environment variable DB_CONNECTION.

If you want to run a specific test, you can do this with this pytest feature:

$ pytest tests/test_api/test_routes/test_users.py::test_user_can_not_take_already_used_credentials

Deployment with Docker

You must have docker and docker-compose tools installed to work with material in this section. First, create .env file like in Quickstart section or modify .env.example. POSTGRES_HOST must be specified as db or modified in docker-compose.yml also. Then just run:

docker-compose up -d db
docker-compose up -d app

Application will be available on localhost in your browser.

Web routes

All routes are available on /docs or /redoc paths with Swagger or ReDoc.

Project structure

Files related to application are in the app or tests directories. Application parts are:

app
├── api              - web related stuff.
│   ├── dependencies - dependencies for routes definition.
│   ├── errors       - definition of error handlers.
│   └── routes       - web routes.
├── core             - application configuration, startup events, logging.
├── db               - db related stuff.
│   ├── migrations   - manually written alembic migrations.
│   └── repositories - all crud stuff.
├── models           - pydantic models for this application.
│   ├── domain       - main models that are used almost everywhere.
│   └── schemas      - schemas for using in web routes.
├── resources        - strings that are used in web responses.
├── services         - logic that is not just crud related.
└── main.py          - FastAPI application creation and configuration.
Issues
  • Steps for running on windows

    Steps for running on windows

    The readme assumes that you're on Linux (can't use EXPORT in Windows)

    opened by stealthrabbi 9
  • Update test running guide

    Update test running guide

    I think this need some guideline to how to run unit test under the test dir for some beginners It will be very helpful, so much thanks

    opened by JasonLee-crypto 6
  • scalability issue

    scalability issue

    fastapi being fast and scalable, but it seems this example won't handle readworld benchmark. To repro, run this and benchmark with wrk -t1 -c100 -d10s --latency http://localhost:8000/api/articles, and any api accessing db is stuck :(

    Maybe we could increase the default MAX_CONNECTIONS_COUNT to a higher value.

    opened by mayli 6
  • Test will try to use docker, even when told not to....

    Test will try to use docker, even when told not to....

    I created a local database that can be approached with ident authentication.

    Then in .env specified: DB_CONNECTION=postgresql+psycopg2:///real_world_application

    In an ipython shell I verified that I can use this string to the database.

    Still $ USE_LOCAL_DB_FOR_TEST=True pytest results in:

    
    During handling of the above exception, another exception occurred:
    ../../../.cache/pypoetry/virtualenvs/fastapi-realworld-example-app-qr8Xy3u9-py3.8/lib/python3.8/site-packages/docker/api/client.py:214: in _retrieve_server_version
        return self.version(api_version=False)["ApiVersion"]
    ../../../.cache/pypoetry/virtualenvs/fastapi-realworld-example-app-qr8Xy3u9-py3.8/lib/python3.8/site-packages/docker/api/daemon.py:181: in version
        return self._result(self._get(url), json=True)
    ../../../.cache/pypoetry/virtualenvs/fastapi-realworld-example-app-qr8Xy3u9-py3.8/lib/python3.8/site-packages/docker/utils/decorators.py:46: in inner
        return f(self, *args, **kwargs)
    ../../../.cache/pypoetry/virtualenvs/fastapi-realworld-example-app-qr8Xy3u9-py3.8/lib/python3.8/site-packages/docker/api/client.py:237: in _get
        return self.get(url, **self._set_request_timeout(kwargs))
    ../../../.cache/pypoetry/virtualenvs/fastapi-realworld-example-app-qr8Xy3u9-py3.8/lib/python3.8/site-packages/requests/sessions.py:555: in get
        return self.request('GET', url, **kwargs)
    ../../../.cache/pypoetry/virtualenvs/fastapi-realworld-example-app-qr8Xy3u9-py3.8/lib/python3.8/site-packages/requests/sessions.py:542: in request
        resp = self.send(prep, **send_kwargs)
    ../../../.cache/pypoetry/virtualenvs/fastapi-realworld-example-app-qr8Xy3u9-py3.8/lib/python3.8/site-packages/requests/sessions.py:655: in send
        r = adapter.send(request, **kwargs)
    ../../../.cache/pypoetry/virtualenvs/fastapi-realworld-example-app-qr8Xy3u9-py3.8/lib/python3.8/site-packages/requests/adapters.py:498: in send
        raise ConnectionError(err, request=request)
    E   requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
    

    (Lots of the above...)

    opened by NL66278 4
  • How to authorize in swagger?

    How to authorize in swagger?

    How to add the authorised button next to the endpoint in swagger? Best regards

    opened by AndreGuerra123 3
  • [Security] Bump pydantic from 1.7.3 to 1.8.1

    [Security] Bump pydantic from 1.7.3 to 1.8.1

    Bumps pydantic from 1.7.3 to 1.8.1.

    Release notes

    Sourced from pydantic's releases.

    v1.8.1

    See Changelog.

    Bug fixes for regressions and new features in v1.8

    v1.8 (2021-02-26)

    See Changelog.

    Thank you to pydantic's sponsors: @​jorgecarleitao, @​BCarley, @​chdsbd, @​tiangolo, @​matin, @​linusg, @​kevinalh, @​koxudaxi, @​timdrijvers, @​mkeen, @​meadsteve, @​ginomempin, @​primer-io, @​and-semakin, @​tomthorogood, @​AjitZK, @​westonsteimel, @​Mazyod, @​christippett, @​CarlosDomingues, @​Kludex, @​r-m-n for their kind support.

    Highlights

    Changes

    • Breaking Change, remove old deprecation aliases from v1, #2415 by @​samuelcolvin:
      • remove notes on migrating to v1 in docs
      • remove Schema which was replaced by Field
      • remove Config.case_insensitive which was replaced by Config.case_sensitive (default False)
      • remove Config.allow_population_by_alias which was replaced by Config.allow_population_by_field_name
      • remove model.fields which was replaced by model.__fields__
      • remove model.to_string() which was replaced by str(model)
      • remove model.__values__ which was replaced by model.__dict__
    • Breaking Change: always validate only first sublevel items with each_item. There were indeed some edge cases with some compound types where the validated items were the last sublevel ones, #1933 by @​PrettyWood
    • Update docs extensions to fix local syntax highlighting, #2400 by @​daviskirk
    • fix: allow utils.lenient_issubclass to handle typing.GenericAlias objects like list[str] in python >= 3.9, #2399 by @​daviskirk
    • Improve field declaration for pydantic dataclass by allowing the usage of pydantic Field or 'metadata' kwarg of dataclasses.field, #2384 by @​PrettyWood
    • Making typing-extensions a required dependency, #2368 by @​samuelcolvin
    • Make resolve_annotations more lenient, allowing for missing modules, #2363 by @​samuelcolvin
    • Allow configuring models through class kwargs, #2356 by @​MrMrRobat
    • Prevent Mapping subclasses from always being coerced to dict, #2325 by @​ofek
    • fix: allow None for type Optional[conset / conlist], #2320 by @​PrettyWood

    ... (truncated)

    Changelog

    Sourced from pydantic's changelog.

    v1.8.1 (2021-03-03)

    Bug fixes for regressions and new features from v1.8

    v1.8 (2021-02-26)

    Thank you to pydantic's sponsors: @​jorgecarleitao, @​BCarley, @​chdsbd, @​tiangolo, @​matin, @​linusg, @​kevinalh, @​koxudaxi, @​timdrijvers, @​mkeen, @​meadsteve, @​ginomempin, @​primer-io, @​and-semakin, @​tomthorogood, @​AjitZK, @​westonsteimel, @​Mazyod, @​christippett, @​CarlosDomingues, @​Kludex, @​r-m-n for their kind support.

    Highlights

    Changes

    • Breaking Change, remove old deprecation aliases from v1, #2415 by @​samuelcolvin:
      • remove notes on migrating to v1 in docs
      • remove Schema which was replaced by Field
      • remove Config.case_insensitive which was replaced by Config.case_sensitive (default False)
      • remove Config.allow_population_by_alias which was replaced by Config.allow_population_by_field_name
      • remove model.fields which was replaced by model.__fields__
      • remove model.to_string() which was replaced by str(model)
      • remove model.__values__ which was replaced by model.__dict__
    • Breaking Change: always validate only first sublevel items with each_item. There were indeed some edge cases with some compound types where the validated items were the last sublevel ones, #1933 by @​PrettyWood
    • Update docs extensions to fix local syntax highlighting, #2400 by @​daviskirk
    • fix: allow utils.lenient_issubclass to handle typing.GenericAlias objects like list[str] in python >= 3.9, #2399 by @​daviskirk
    • Improve field declaration for pydantic dataclass by allowing the usage of pydantic Field or 'metadata' kwarg of dataclasses.field, #2384 by @​PrettyWood
    • Making typing-extensions a required dependency, #2368 by @​samuelcolvin
    • Make resolve_annotations more lenient, allowing for missing modules, #2363 by @​samuelcolvin
    • Allow configuring models through class kwargs, #2356 by @​MrMrRobat
    • Prevent Mapping subclasses from always being coerced to dict, #2325 by @​ofek
    • fix: allow None for type Optional[conset / conlist], #2320 by @​PrettyWood
    • Support empty tuple type, #2318 by @​PrettyWood
    • fix: python_requires metadata to require >=3.6.1, #2306 by @​hukkinj1

    ... (truncated)

    Commits
    • 619ff26 prepare for v1.8.1
    • 62bb2ad allow Config.field to update a Field (#2461)
    • 3f84d14 fix: validation with a BaseModel field and a custom root type (#2451)
    • ab69114 fix: avoid RecursionError when using some types like Enum or Literal wi...
    • 429b439 Allow for generation of a constrained float with multiple_of argument for hyp...
    • a74232e fix: variable length tuples of compound types (#2421)
    • 37c37fd fix(mypy): fix custom Path and UUID related types (#2420)
    • b2d3f33 refactor: set Pattern encoder in ENCODERS_BY_TYPE (#2444)
    • 9bd2da7 fix: docs indentation (#2448)
    • d619457 fix: docs indent (#2440)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Pull request limits (per update run and/or open at any time)
    • Automerge options (never/patch/minor, and dev/runtime dependencies)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)
    dependencies security 
    opened by dependabot-preview[bot] 3
  • Set proper host in DB_CONNECTION in .env.example

    Set proper host in DB_CONNECTION in .env.example

    Now: DB_CONNECTION=postgres://postgres:[email protected]/postgres

    Expected: DB_CONNECTION=postgres://postgres:[email protected]db/postgres

    The hostname for connection is the same as a service name, so this information is considered permanent.

    opened by funnydman 3
  • Bump databases from 0.4.3 to 0.5.0

    Bump databases from 0.4.3 to 0.5.0

    Bumps databases from 0.4.3 to 0.5.0.

    Release notes

    Sourced from databases's releases.

    Version 0.5.0

    0.5.0 (August 26th, 2021)

    Added

    • Support SQLAlchemy 1.4 (#299)

    Fixed

    • Fix concurrent transactions (#328)
    Changelog

    Sourced from databases's changelog.

    0.5.0 (August 26th, 2021)

    Added

    • Support SQLAlchemy 1.4 (#299)

    Fixed

    • Fix concurrent transactions (#328)
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies python 
    opened by dependabot[bot] 3
  • Bump attrs from 19.3.0 to 20.2.0

    Bump attrs from 19.3.0 to 20.2.0

    Bumps attrs from 19.3.0 to 20.2.0.

    Release notes

    Sourced from attrs's releases.

    20.2.0

    Backward-incompatible Changes

    • attr.define(), attr.frozen(), attr.mutable(), and attr.field() remain provisional.

      This release fixes a bunch of bugs and ergonomics but they remain mostly unchanged.

      If you wish to use them together with mypy, you can simply drop this plugin into your project.

      Feel free to provide feedback to them in the linked issue #668.

      We will release the attrs namespace once we have the feeling that the APIs have properly settled. #668

    Changes

    • attr.define() et al now correct detect __eq__ and __ne__. #671

    • attr.define() et al's hybrid behavior now also works correctly when arguments are passed. #675

    • It's possible to define custom __setattr__ methods on slotted classes again. #681

    • In 20.1.0 we introduced the inherited attribute on the attr.Attribute class to differentiate attributes that have been inherited and those that have been defined directly on the class.

      It has shown to be problematic to involve that attribute when comparing instances of attr.Attribute though, because when sub-classing, attributes from base classes are suddenly not equal to themselves in a super class.

      Therefore the inherited attribute will now be ignored when hashing and comparing instances of attr.Attribute. #684

    • zope.interface is now a "soft dependency" when running the test suite; if zope.interface is not installed when running the test suite, the interface-related tests will be automatically skipped. #685

    • The ergonomics of creating frozen classes using @define(frozen=True) and sub-classing frozen classes has been improved: you don't have to set on_setattr=None anymore. #687

    20.1.0

    Backward-incompatible Changes

    • Python 3.4 is not supported anymore. It has been unsupported by the Python core team for a while now, its PyPI downloads are negligible, and our CI provider removed it as a supported option.

      It's very unlikely that attrs will break under 3.4 anytime soon, which is why we do not block its installation on Python 3.4. But we don't test it anymore and will block it once someone reports breakage. #608

    Deprecations

    • Less of a deprecation and more of a heads up: the next release of attrs will introduce an attrs namespace. That means that you'll finally be able to run import attrs with new functions that aren't cute abbreviations and that will carry better defaults.

      This should not break any of your code, because project-local packages have priority before installed ones. If this is a problem for you for some reason, please report it to our bug tracker and we'll figure something out.

      The old attr namespace isn't going anywhere and its defaults are not changing -- this is a purely additive measure. Please check out the linked issue for more details.

    Changelog

    Sourced from attrs's changelog.

    20.2.0 (2020-09-05)

    Backward-incompatible Changes

    • attr.define(), attr.frozen(), attr.mutable(), and attr.field() remain provisional.

      This release fixes a bunch of bugs and ergonomics but they remain mostly unchanged.

      If you wish to use them together with mypy, you can simply drop this plugin into your project.

      Feel free to provide feedback to them in the linked issue #668.

      We will release the attrs namespace once we have the feeling that the APIs have properly settled. #668

    Changes

    • attr.define() et al now correct detect __eq__ and __ne__. #671

    • attr.define() et al's hybrid behavior now also works correctly when arguments are passed. #675

    • It's possible to define custom __setattr__ methods on slotted classes again. #681

    • In 20.1.0 we introduced the inherited attribute on the attr.Attribute class to differentiate attributes that have been inherited and those that have been defined directly on the class.

      It has shown to be problematic to involve that attribute when comparing instances of attr.Attribute though, because when sub-classing, attributes from base classes are suddenly not equal to themselves in a super class.

      Therefore the inherited attribute will now be ignored when hashing and comparing instances of attr.Attribute. #684

    • zope.interface is now a "soft dependency" when running the test suite; if zope.interface is not installed when running the test suite, the interface-related tests will be automatically skipped. #685

    • The ergonomics of creating frozen classes using @define(frozen=True) and sub-classing frozen classes has been improved: you don't have to set on_setattr=None anymore. #687


    20.1.0 (2020-08-20)

    Backward-incompatible Changes

    • Python 3.4 is not supported anymore. It has been unsupported by the Python core team for a while now, its PyPI downloads are negligible, and our CI provider removed it as a supported option.

      It's very unlikely that attrs will break under 3.4 anytime soon, which is why we do not block its installation on Python 3.4. But we don't test it anymore and will block it once someone reports breakage. #608

    Deprecations

    • Less of a deprecation and more of a heads up: the next release of attrs will introduce an attrs namespace. That means that you'll finally be able to run import attrs with new functions that aren't cute abbreviations and that will carry better defaults.

      This should not break any of your code, because project-local packages have priority before installed ones. If this is a problem for you for some reason, please report it to our bug tracker and we'll figure something out.

      The old attr namespace isn't going anywhere and its defaults are not changing – this is a purely additive measure. Please check out the linked issue for more details.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Pull request limits (per update run and/or open at any time)
    • Automerge options (never/patch/minor, and dev/runtime dependencies)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)
    dependencies 
    opened by dependabot-preview[bot] 2
  • Bump testfixtures from 6.14.1 to 6.14.2

    Bump testfixtures from 6.14.1 to 6.14.2

    Bumps testfixtures from 6.14.1 to 6.14.2.

    Changelog

    Sourced from testfixtures's changelog.

    6.14.2 (4 Sep 2020)

    • Fix bug where ignore_eq had no effect on nested objects when using compare.

    Thanks to Grégoire Payen de La Garanderie for the fix.

    Commits
    • a02097a Prepare for 6.14.2 release.
    • 518089c Merge pull request #137 from gdlg/ignore_eq
    • 0e398f0 Always compare object mappings when ignore_eq is enabled.
    • 9684e98 fix for python 3.8.3
    • ffa52d9 Merge pull request #135 from dspinellis/patch-1
    • f0e01cb Change module references to package
    • 826f7ea Correct confusing name and fix typos
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Pull request limits (per update run and/or open at any time)
    • Automerge options (never/patch/minor, and dev/runtime dependencies)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)
    dependencies 
    opened by dependabot-preview[bot] 2
  • queries.pyi / aiosql

    queries.pyi / aiosql

    I'm attempting to create a new table entity, and writing a repository to query the database.

    1. I was trying to figure out how to update env.py to support auto-generation with alembic, but wasn't sure where the "base metadata" lives, or how to specify it exactly. Do I need a file that imports all the models in app/models/domain?
    2. queries.py references queries.pyi. The readme doesn't specify how to use aiosql, so I'm not sure what to do with it exactly. Is it required for doing queries?
    opened by stealthrabbi 1
  • 500 error getting articles

    500 error getting articles

    Testing with zap-api-scan.py I have discovered various 500 status codes in the API. For example: curl -X GET "http://localhost:8000/api/articles?tag=%00&author=author&favorited=favorited&limit=20&offset=0" -H "accept: application/json" The complete report look like this:

    ZAP Scanning Report

    Generated on Thu, 25 Feb 2021 15:54:01

    Summary of Alerts

    | Risk Level | Number of Alerts | | --- | --- | | High | 0 | | Medium | 0 | | Low | 3 | | Informational | 1 |

    Alerts

    | Name | Risk Level | Number of Instances | | --- | --- | --- | | A Server Error response code was returned by the server | Low | 3 | | Unexpected Content-Type was returned | Low | 3 | | X-Content-Type-Options Header Missing | Low | 3 | | A Client Error response code was returned by the server | Informational | 435 |

    Alert Detail

    A Server Error response code was returned by the server

    Low (High)

    Description

    A response code of 500 was returned by the server.

    This may indicate that the application is failing to handle unexpected input correctly.

    Raised by the 'Alert on HTTP Response Code Error' script

    Instances: 3

    Solution

    Reference

    CWE Id : 388

    WASC Id : 20

    Source ID : 4

    Unexpected Content-Type was returned

    Low (High)

    Description

    A Content-Type of text/plain was returned by the server.

    This is not one of the types expected to be returned by an API.

    Raised by the 'Alert on Unexpected Content Types' script

    Instances: 3

    Solution

    Reference

    Source ID : 4

    X-Content-Type-Options Header Missing

    Low (Medium)

    Description

    The Anti-MIME-Sniffing header X-Content-Type-Options was not set to 'nosniff'. This allows older versions of Internet Explorer and Chrome to perform MIME-sniffing on the response body, potentially causing the response body to be interpreted and displayed as a content type other than the declared content type. Current (early 2014) and legacy versions of Firefox will use the declared content type (if one is set), rather than performing MIME-sniffing.

    Instances: 3

    Solution

    Ensure that the application/web server sets the Content-Type header appropriately, and that it sets the X-Content-Type-Options header to 'nosniff' for all web pages.

    If possible, ensure that the end user uses a standards-compliant and modern web browser that does not perform MIME-sniffing at all, or that can be directed by the web application/web server to not perform MIME-sniffing.

    Other information

    This issue still applies to error type pages (401, 403, 500, etc.) as those pages are often still affected by injection issues, in which case there is still concern for browsers sniffing pages away from their actual content type.

    At "High" threshold this scan rule will not alert on client or server error responses.

    Reference

    • http://msdn.microsoft.com/en-us/library/ie/gg622941%28v=vs.85%29.aspx
    • https://owasp.org/www-community/Security_Headers

    CWE Id : 16

    WASC Id : 15

    Source ID : 3

    A Client Error response code was returned by the server

    Informational (High)

    Description

    A response code of 404 was returned by the server.

    This may indicate that the application is failing to handle unexpected input correctly.

    Raised by the 'Alert on HTTP Response Code Error' script

    Instances: 435

    Solution

    Reference

    CWE Id : 388

    WASC Id : 20

    Source ID : 4

    opened by RubenPozoMolina 0
  • Use pydantic's BaseSettings for configuration instead of startlette's config

    Use pydantic's BaseSettings for configuration instead of startlette's config

    FastAPI recommends using BaseSettings for confiugration. It would be nice for this example to follow that recommendation. See https://fastapi.tiangolo.com/advanced/settings/

    opened by robhobbes 1
  • Can you talk more about how you split queries between aiosql and pypika?

    Can you talk more about how you split queries between aiosql and pypika?

    This repository has shown me a very interesting way of organsing the db logic and I'm interested in the reasons behind your decisions. Thank you! (It's really amazing work and really helpful.)

    opened by npalladium 5
  • Add documentation

    Add documentation

    It will be great to have a detailed documentation that covers directory structure, app functionalities. This will really help new users to be able to grasp your work easily.

    opened by rishabh96b 1
  • Alembic configuration

    Alembic configuration

    Is alembic configured correctly? When I change the model, and run alembic revision, it generates an empty migration. It does not seem to pick up the changes made in models files.

    opened by Euphorbium 1
Owner
Nik
Student. Currently Elixir backend developer. Python/Rust/Elixir + some other
Nik
FastAPI Admin Dashboard based on FastAPI and Tortoise ORM.

FastAPI ADMIN 中文文档 Introduction FastAPI-Admin is a admin dashboard based on fastapi and tortoise-orm. FastAPI-Admin provide crud feature out-of-the-bo

long2ice 929 Oct 23, 2021
Ready-to-use and customizable users management for FastAPI

FastAPI Users Ready-to-use and customizable users management for FastAPI Documentation: https://frankie567.github.io/fastapi-users/ Source Code: https

François Voron 1.3k Oct 23, 2021
官方文档已经有翻译的人在做了,

FastAPI 框架,高性能,易学,快速编码,随时可供生产 文档:https://fastapi.tiangolo.com 源码:https://github.com/tiangolo/fastapi FastAPI 是一个现代、快速(高性能)的 Web 框架,基于标准 Python 类型提示,使用

ApacheCN 27 Jun 28, 2021
FastAPI构建的API服务

使用FastAPI 构建的商城项目API 学习FastAPI 构建项目目录 构建项目接口: 对应博客:https://www.charmcode.cn/article/2020-06-08_vue_mall_api 声明 此项目已经不再维护, 可以参考我另外一个项目https://github.co

王小右 47 Sep 7, 2021
FastAPI framework plugins

Plugins for FastAPI framework, high performance, easy to learn, fast to code, ready for production fastapi-plugins FastAPI framework plugins Cache Mem

RES 163 Oct 14, 2021
Backend, modern REST API for obtaining match and odds data crawled from multiple sites. Using FastAPI, MongoDB as database, Motor as async MongoDB client, Scrapy as crawler and Docker.

Introduction Apiestas is a project composed of a backend powered by the awesome framework FastAPI and a crawler powered by Scrapy. This project has fo

Fran Lozano 43 Oct 9, 2021
Reusable utilities for FastAPI

Reusable utilities for FastAPI Documentation: https://fastapi-utils.davidmontague.xyz Source Code: https://github.com/dmontagu/fastapi-utils FastAPI i

David Montague 868 Oct 22, 2021
row level security for FastAPI framework

Row Level Permissions for FastAPI While trying out the excellent FastApi framework there was one peace missing for me: an easy, declarative way to def

Holger Frey 187 Oct 17, 2021
The base to start an openapi project featuring: SQLModel, Typer, FastAPI, JWT Token Auth, Interactive Shell, Management Commands.

The base to start an openapi project featuring: SQLModel, Typer, FastAPI, JWT Token Auth, Interactive Shell, Management Commands.

Bruno Rocha 56 Oct 17, 2021
api versioning for fastapi web applications

fastapi-versioning api versioning for fastapi web applications Installation pip install fastapi-versioning Examples from fastapi import FastAPI from f

Dean Way 303 Oct 21, 2021
JSON-RPC server based on fastapi

Description JSON-RPC server based on fastapi: https://fastapi.tiangolo.com Motivation Autogenerated OpenAPI and Swagger (thanks to fastapi) for JSON-R

null 125 Oct 14, 2021
a lightweight web framework based on fastapi

start-fastapi Version 2021, based on FastAPI, an easy-to-use web app developed upon Starlette Framework Version 2020 中文文档 Requirements python 3.6+ (fo

HiKari 61 Sep 29, 2021
Monitor Python applications using Spring Boot Admin

Pyctuator Monitor Python web apps using Spring Boot Admin. Pyctuator supports Flask, FastAPI, aiohttp and Tornado. Django support is planned as well.

SolarEdge Technologies 97 Oct 22, 2021
基于Pytorch的脚手架项目,Celery+FastAPI+Gunicorn+Nginx+Supervisor实现服务部署,支持Docker发布

cookiecutter-pytorch-fastapi 基于Pytorch的 脚手架项目 按规范添加推理函数即可实现Celery+FastAPI+Gunicorn+Nginx+Supervisor+Docker的快速部署 Requirements Python >= 3.6 with pip in

null 12 Oct 15, 2021
FastAPI on Google Cloud Run

cloudrun-fastapi Boilerplate for running FastAPI on Google Cloud Run with Google Cloud Build for deployment. For all documentation visit the docs fold

Anthony Corletti 65 Oct 5, 2021
Minimal example utilizing fastapi and celery with RabbitMQ for task queue, Redis for celery backend and flower for monitoring the celery tasks.

FastAPI with Celery Minimal example utilizing FastAPI and Celery with RabbitMQ for task queue, Redis for Celery backend and flower for monitoring the

Grega Vrbančič 244 Oct 15, 2021
FastAPI Boilerplate

FastAPI Boilerplate Features SQlAlchemy session Custom user class Top-level dependency Dependencies for specific permissions Celery SQLAlchemy for asy

Hide 62 Oct 15, 2021
FastAPI Skeleton App to serve machine learning models production-ready.

FastAPI Model Server Skeleton Serving machine learning models production-ready, fast, easy and secure powered by the great FastAPI by Sebastián Ramíre

null 208 Oct 20, 2021
Auth for use with FastAPI

FastAPI Auth Pluggable auth for use with FastAPI Supports OAuth2 Password Flow Uses JWT access and refresh tokens 100% mypy and test coverage Supports

David Montague 59 Oct 6, 2021