Skip to main content

FastAPI Request Helper

Project description

FastAPI Request helper

How to use

  1. Set a variable
# user_service.py
from fastapi import FastAPI
from fastapi_global_variable import GlobalVariable

app = FastAPI(title="Application")

GlobalVariable.set('app', app)
  1. Use variable
from fastapi_global_variable import GlobalVariable

print(GlobalVariable.get_or_fail('app'))
print(GlobalVariable.get('app'))
  1. Decorators

FastAPI Request Helper provides lots of helpful decorators:

  • Swagger docs decorators: @controller, @tag, @get, @post, @put, @delete, @patch
  • Rate limit request: @rate_limit
  • FastAPI response model: @response
  • FastAPI guards: @guard, @gurads
  • FastAPI response status: @status
  • FastAPI API info details: @description, @summary, @name
  • FastAPI API response status: @status_no_content, @status_ok, @status_created
  • Hide API: @hidden_when(condition: boolean)

Fast API Helper also provides Pagination Query params helper: PaginationParams

# Sample
from fastapi_request_helper import (
    controller,
    post,
    rate_limit,
    response,
    status_created,
    status_no_content,
    status_ok,
    tag,
)

@controller('authentications')
@tag('Authentication')
class AuthenticationController:
    def __init__(self, auth_service: AuthenticationService = Depends()):
        self.auth_service = auth_service

    @post('create-email-otp')
    @status_no_content()
    async def create_email_otp(self):
        pass

How to test in testpypi

  1. Setup file .pypirc
$ cd ~/
$ vim .pypirc

Copy to file .pypirc

[pypi]
username=****
password=****

[testpypi]
username=__token__
password=*****

[distutils]

index-servers =
  pypi
  testpypi
  gitlab

[gitlab]
repository = https://gitlab.com/api/v4/projects/50838104/packages/pypi
username = gitlab+deploy-token-3497403
password = ****
  1. Increase the version in pyproject.toml
  2. Run command
$ ./build_and_test.sh
  1. install package
$ pip install --no-cache-dir --upgrade -i https://test.pypi.org/simple/ fastapi-request-helper==x.y.z --no-dependencies
$ pip install -i https://test.pypi.org/simple/ fastapi-request-helper==x.y.z

How to publish new version

  1. Increase the version in pyproject.toml
  2. Run command
$ ./build_and_publish.sh

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_request_helper-0.0.16.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_request_helper-0.0.16-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_request_helper-0.0.16.tar.gz.

File metadata

  • Download URL: fastapi_request_helper-0.0.16.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for fastapi_request_helper-0.0.16.tar.gz
Algorithm Hash digest
SHA256 858ea23afe7189032e297da1b2d5dcf9c9be8496c1f80369cdc6bdf37b408dbc
MD5 4520dea89356e7d87cabe466dc296294
BLAKE2b-256 0658ec8e1605d215f146aa6f5712d327262f86e37d96925b81ea63c72b12a03a

See more details on using hashes here.

File details

Details for the file fastapi_request_helper-0.0.16-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_request_helper-0.0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 f2e5aede0653cf1604e6cba40ce8088096e4c3b031355f5f92efecaab7fcc9dd
MD5 82fd598704b0c664a820a24f8cf8a727
BLAKE2b-256 116fb223df9443685bdc2e94597ff92996de6ffe512854632ae95e6cc16dd591

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page