FastAPI Microservice Helper
Project description
FastAPI Request helper
How to use
- Set a variable
# user_service.py
from fastapi import FastAPI
from fastapi_global_variable import GlobalVariable
app = FastAPI(title="Application")
GlobalVariable.set('app', app)
- Use variable
from fastapi_global_variable import GlobalVariable
print(GlobalVariable.get_or_fail('app'))
print(GlobalVariable.get('app'))
- 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
- Increase the version in
pyproject.toml
- Run command
$ ./build_and_test.sh
How to publish new version
- Increase the version in
pyproject.toml
- Run command
$ ./build_and_publish.sh
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for fastapi_microservice_helper-0.0.16.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7ca65b4aa56a623885f7d374285cbf9d708bf42a464660929fcec6a89aea19b |
|
MD5 | c59b3cfff0691f9a1cbf7ccb8f7eb91d |
|
BLAKE2b-256 | 8266f620bc20b9f6c2757653545bf38b7833dc49b0eed940301df7f756c4d9aa |
Close
Hashes for fastapi_microservice_helper-0.0.16-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 591168b67284d2a879aaf88a0512ec4664d5a2f3420ea9c44b60afde6f2e1201 |
|
MD5 | ee05a0de48bb7b9ea8036f2a11dd1a79 |
|
BLAKE2b-256 | c847d4b75fc3e9a3b5e12e61896ccb3f52862e84b661df4a588cad46e5a1ae91 |