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.29.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a701b48361ca6cbd7863f1bb43a1aa1caad7e0c43a0c5ec77bfce01b049bc6d3 |
|
MD5 | 7110a85fd97218a60435c0745916d785 |
|
BLAKE2b-256 | 518831d9af783bf33f7b8f23f446eaa9ae1c208cc3340bf2fe0f05553af80ca8 |
Close
Hashes for fastapi_microservice_helper-0.0.29-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ea62765fd68c369b49c3267c43102c228fd1651bbcb072b82d091e1fb9e9dba |
|
MD5 | b672eb3ac5f1422dc91127ec50929071 |
|
BLAKE2b-256 | 65594298b34ba4f8acbdbadf5ea259320335d14a5eb4c91e9f56639c0da5842e |