Skip to main content

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

Metadata

Release files for fastapi-request-helper 0.0.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastapi-request-helper 0.0.17
File Size Uploaded Provenance Actions
fastapi_request_helper-0.0.17.tar.gz 7.5 kB Without provenance Details for fastapi_request_helper-0.0.17.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-request-helper 0.0.17
File Interpreter ABI Platform Actions
fastapi_request_helper-0.0.17-py3-none-any.whl Python 3 none any Details for fastapi_request_helper-0.0.17-py3-none-any.whl

Total release size: 15.3 kB

Release files / fastapi_request_helper-0.0.17.tar.gz

Download URL fastapi_request_helper-0.0.17.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
44fecc931a7c2a9ab8960ba6b76815dbccaec8e6b8556fcb8139e30c1f9e4b6e
BLAKE2b-256 checksum
How to use checksums
028375f4a1b051eb75086d649162d7cbdc3c6072c6526eaea417fc1dae871166
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Release files / fastapi_request_helper-0.0.17-py3-none-any.whl

Download URL fastapi_request_helper-0.0.17-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7900f62d3231e4bd92b13f9bfa17b2ee8954bae22cf35d17e7936877b7867fad
BLAKE2b-256 checksum
How to use checksums
413e783fa2af09b6af5b664bd9a54ca2e50844c452aea1b33da2cf31cabaf0b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Security for fastapi-request-helper 0.0.17

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page