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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zogutils-1.2.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file zogutils-1.2.1.tar.gz.

File metadata

  • Download URL: zogutils-1.2.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.7.7 Darwin/19.6.0

File hashes

Hashes for zogutils-1.2.1.tar.gz
Algorithm Hash digest
SHA256 ce3090460800b9cd8974c9c0dafa4778a8c47d4019446594ecb91351d1df2ad0
MD5 79db9f4dea28dc3b7323d19b204dbf1f
BLAKE2b-256 b696a7a805d5608cded1ba83b92ac25d2cb392f5a32a28deda889ffc4febbcca

See more details on using hashes here.

File details

Details for the file zogutils-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: zogutils-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.10 CPython/3.7.7 Darwin/19.6.0

File hashes

Hashes for zogutils-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ed2abd099842d08e02d9ad01c43e58fcba74afed86758511c64eddb76af80e7e
MD5 37ee88446dbb736c7a1cff7cc0d42073
BLAKE2b-256 76c2b3ed9e4680f5c25128ac4f3eaac1c436556af188cd1f6fdf44214ee7146e

See more details on using hashes here.

Supported by

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