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.19.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for fastapi_microservice_helper-0.0.19.tar.gz
Algorithm Hash digest
SHA256 a063f63f471e7b80f6a7021924dd6603aa99348501b28f6e1ebbd9b3679c7296
MD5 48c9521e19502889bb78f08b83e36b54
BLAKE2b-256 4771a76d7a1e153b1fd32199da9cbce582811d3646083fb7d9553ff91eda3e71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_microservice_helper-0.0.19-py3-none-any.whl
Algorithm Hash digest
SHA256 4b6871b62e8354a0d2f0643440bf03326fc2c42389b1c66a3ddd9684de0ac801
MD5 d58c2be53bc28ad2916017ad4e98b5d5
BLAKE2b-256 3bf46b80fbbccf32ac9906fe9f8991a96d4483d1e0ec14988c26256b86008520

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