Skip to main content

General utilities to be use in my base-fastapi template. Why ZOG? It's sound like joke and look like zoo.

Project description

ZOG Utils

Utilities to use in my base-api project template. https://github.com/tienhm0202/base-fastapi/

Why ZOG? Because I can't named it as utils only, so I have to add a prefix. ZOG sounds like joke and looks like zoo. I found that funny enough to use.

Usage

$ pip install zogutils

To generate short unique id string

from zogutils import secret

secret.unique_id(8, "ID_")
# return: ID_a7uFg9k0

To shorten package name like Java's Logback

from zogutils import package_name

package_name.shorten("company.scope.modules.Function", 9)
# return: (something like) c.s.m.Function - depends on max length

To init some middlewares

from zogutils import middlewares
from your.app import settings, fastapi_app

middlewares.init_app(fastapi_app, settings)

Configs:

# Sentry
SENTRY_DSN: Optional[HttpUrl] = None
SENTRY_INCLUDE: Optional[List[str]] = ["src"]
SENTRY_SAMPLE_RATE: Optional[float] = 0.5

# CSRF
SECURITY_CSRF: bool = False

# Rate limit
RATE_LIMIT: int = 100
RATE_LIMIT_TIME_SPAN: int = 30
RATE_LIMIT_BLOCK_DURATION: int = 300

# Prometheus
PROMETHEUS_ENABLE: bool = True
PROMETHEUS_PATH: str = "/metrics/"

# Cors
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = []

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

zogutils-1.5.1.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

zogutils-1.5.1-py3-none-any.whl (6.2 kB view hashes)

Uploaded Python 3

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