Skip to main content

FastAPI Microservice 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. Increase the version in pyproject.toml
  2. Run command
$ ./build_and_test.sh

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_microservice_helper-0.0.20.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file fastapi_microservice_helper-0.0.20.tar.gz.

File metadata

File hashes

Hashes for fastapi_microservice_helper-0.0.20.tar.gz
Algorithm Hash digest
SHA256 02d6f309abfa98a6b3edc95191e41c03960a719c1f99f47450e7492408d2ef5e
MD5 d92d59c54c3ac995ff397d4bc4c99750
BLAKE2b-256 f55ec3a056cc579049d099b30a16eb5bc65627e612327c9998ad98b73ec382c8

See more details on using hashes here.

File details

Details for the file fastapi_microservice_helper-0.0.20-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_microservice_helper-0.0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 7825a92edb5e8b0bef6cf970f3a84d9ca177695db32fd1e71e5a6e027314ad4b
MD5 61d96cc8f3670b29711a75e773d7c9c1
BLAKE2b-256 b1da093ec70bdc6b9f1d424a8d30d30734077d33e64b8f1c0e0937018c498c84

See more details on using hashes here.

Supported by

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