
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
starlette-compress is a fast and simple middleware for compressing responses in Starlette. It supports more compression algorithms than Starlette's built-in GZipMiddleware, and has more sensible defaults.
compression.zstd
supportasyncio
and trio
backendspip install starlette-compress
from starlette.applications import Starlette
from starlette.middleware import Middleware
from starlette_compress import CompressMiddleware
middleware = [
Middleware(CompressMiddleware)
]
app = Starlette(routes=..., middleware=middleware)
You can use starlette-compress with FastAPI too:
from fastapi import FastAPI
from starlette_compress import CompressMiddleware
app = FastAPI()
app.add_middleware(CompressMiddleware)
Control the minimum size of the response to compress. By default, responses must be at least 500 bytes to be compressed.
# Starlette
middleware = [
Middleware(CompressMiddleware, minimum_size=1000)
]
# FastAPI
app.add_middleware(CompressMiddleware, minimum_size=1000)
Adjust the compression levels for each algorithm. Higher levels mean smaller files but slower compression. Default level is 4 for all algorithms.
# Starlette
middleware = [
Middleware(CompressMiddleware, zstd_level=6, brotli_quality=6, gzip_level=6)
]
# FastAPI
app.add_middleware(CompressMiddleware, zstd_level=6, brotli_quality=6, gzip_level=6)
Manage the supported content-types. Unknown response types are not compressed. Check here for the default configuration.
from starlette_compress import add_compress_type, remove_compress_type
add_compress_type("application/my-custom-type")
remove_compress_type("application/json")
FAQs
Compression middleware for Starlette - supporting ZStd, Brotli, and GZip
We found that starlette-compress demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.