mirror of
https://github.com/aljazceru/nutshell.git
synced 2026-01-11 12:44:19 +01:00
disable starlette_context
This commit is contained in:
@@ -5,8 +5,9 @@ from fastapi import FastAPI
|
||||
from loguru import logger
|
||||
from starlette.middleware import Middleware
|
||||
from starlette.middleware.base import BaseHTTPMiddleware
|
||||
from starlette_context import context
|
||||
from starlette_context.middleware import RawContextMiddleware
|
||||
|
||||
# from starlette_context import context
|
||||
# from starlette_context.middleware import RawContextMiddleware
|
||||
|
||||
from cashu.core.settings import DEBUG, VERSION
|
||||
|
||||
@@ -14,15 +15,15 @@ from .router import router
|
||||
from .startup import start_mint_init
|
||||
|
||||
|
||||
class CustomHeaderMiddleware(BaseHTTPMiddleware):
|
||||
"""
|
||||
Middleware for starlette that can set the context from request headers
|
||||
"""
|
||||
# class CustomHeaderMiddleware(BaseHTTPMiddleware):
|
||||
# """
|
||||
# Middleware for starlette that can set the context from request headers
|
||||
# """
|
||||
|
||||
async def dispatch(self, request, call_next):
|
||||
context["client-version"] = request.headers.get("Client-version")
|
||||
response = await call_next(request)
|
||||
return response
|
||||
# async def dispatch(self, request, call_next):
|
||||
# context["client-version"] = request.headers.get("Client-version")
|
||||
# response = await call_next(request)
|
||||
# return response
|
||||
|
||||
|
||||
def create_app(config_object="core.settings") -> FastAPI:
|
||||
@@ -60,12 +61,12 @@ def create_app(config_object="core.settings") -> FastAPI:
|
||||
|
||||
configure_logger()
|
||||
|
||||
middleware = [
|
||||
Middleware(
|
||||
RawContextMiddleware,
|
||||
),
|
||||
Middleware(CustomHeaderMiddleware),
|
||||
]
|
||||
# middleware = [
|
||||
# Middleware(
|
||||
# RawContextMiddleware,
|
||||
# ),
|
||||
# Middleware(CustomHeaderMiddleware),
|
||||
# ]
|
||||
|
||||
app = FastAPI(
|
||||
title="Cashu Mint",
|
||||
@@ -75,7 +76,7 @@ def create_app(config_object="core.settings") -> FastAPI:
|
||||
"name": "MIT License",
|
||||
"url": "https://raw.githubusercontent.com/callebtc/cashu/main/LICENSE",
|
||||
},
|
||||
middleware=middleware,
|
||||
# middleware=middleware,
|
||||
)
|
||||
return app
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ import math
|
||||
from typing import Dict, List, Set
|
||||
|
||||
from loguru import logger
|
||||
from starlette_context import context
|
||||
|
||||
# from starlette_context import context
|
||||
|
||||
import cashu.core.b_dhke as b_dhke
|
||||
import cashu.core.bolt11 as bolt11
|
||||
@@ -19,7 +20,6 @@ from cashu.core.base import (
|
||||
MintKeysets,
|
||||
Proof,
|
||||
)
|
||||
from cashu.core.crypto import derive_keys, derive_keyset_id, derive_pubkeys
|
||||
from cashu.core.db import Database
|
||||
from cashu.core.helpers import fee_reserve, sum_proofs
|
||||
from cashu.core.script import verify_script
|
||||
@@ -70,7 +70,6 @@ class Ledger:
|
||||
"""Loads all keysets from db."""
|
||||
self.keyset = await self.load_keyset(self.derivation_path)
|
||||
# load all past keysets from db
|
||||
# this needs two steps because the types of tmp_keysets and the argument of MintKeysets() are different
|
||||
tmp_keysets: List[MintKeyset] = await self.crud.get_keyset(db=self.db)
|
||||
self.keysets = MintKeysets(tmp_keysets)
|
||||
logger.debug(f"Loading {len(self.keysets.keysets)} keysets form db.")
|
||||
|
||||
19
poetry.lock
generated
19
poetry.lock
generated
@@ -168,7 +168,7 @@ starlette = "0.19.1"
|
||||
all = ["email_validator (>=1.1.1,<2.0.0)", "itsdangerous (>=1.1.0,<3.0.0)", "jinja2 (>=2.11.2,<4.0.0)", "orjson (>=3.2.1,<4.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "pyyaml (>=5.3.1,<7.0.0)", "requests (>=2.24.0,<3.0.0)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,<6.0.0)", "uvicorn[standard] (>=0.12.0,<0.18.0)"]
|
||||
dev = ["autoflake (>=1.4.0,<2.0.0)", "flake8 (>=3.8.3,<6.0.0)", "passlib[bcrypt] (>=1.7.2,<2.0.0)", "pre-commit (>=2.17.0,<3.0.0)", "python-jose[cryptography] (>=3.3.0,<4.0.0)", "uvicorn[standard] (>=0.12.0,<0.18.0)"]
|
||||
doc = ["mdx-include (>=1.4.1,<2.0.0)", "mkdocs (>=1.1.2,<2.0.0)", "mkdocs-markdownextradata-plugin (>=0.1.7,<0.3.0)", "mkdocs-material (>=8.1.4,<9.0.0)", "pyyaml (>=5.3.1,<7.0.0)", "typer (>=0.4.1,<0.5.0)"]
|
||||
test = ["anyio[trio] (>=3.2.1,<4.0.0)", "black (==22.3.0)", "databases[sqlite] (>=0.3.3,<0.6.0)", "email_validator (>=1.1.1,<2.0.0)", "flake8 (>=3.8.3,<6.0.0)", "flask (>=1.1.2,<3.0.0)", "httpx (>=0.14.0,<0.19.0)", "isort (>=5.0.6,<6.0.0)", "mypy (==0.910)", "orjson (>=3.2.1,<4.0.0)", "peewee (>=3.13.3,<4.0.0)", "pytest (>=6.2.4,<7.0.0)", "pytest-cov (>=2.12.0,<4.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "requests (>=2.24.0,<3.0.0)", "sqlalchemy (>=1.3.18,<1.5.0)", "types-dataclasses (==0.6.5)", "types-orjson (==3.6.2)", "types-ujson (==4.2.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,<6.0.0)"]
|
||||
test = ["anyio[trio] (>=3.2.1,<4.0.0)", "black (==22.3.0)", "databases[sqlite] (>=0.3.2,<0.6.0)", "email_validator (>=1.1.1,<2.0.0)", "flake8 (>=3.8.3,<6.0.0)", "flask (>=1.1.2,<3.0.0)", "httpx (>=0.14.0,<0.19.0)", "isort (>=5.0.6,<6.0.0)", "mypy (==0.910)", "orjson (>=3.2.1,<4.0.0)", "peewee (>=3.13.3,<4.0.0)", "pytest (>=6.2.4,<7.0.0)", "pytest-cov (>=2.12.0,<4.0.0)", "python-multipart (>=0.0.5,<0.0.6)", "requests (>=2.24.0,<3.0.0)", "sqlalchemy (>=1.3.18,<1.5.0)", "types-dataclasses (==0.6.5)", "types-orjson (==3.6.2)", "types-ujson (==4.2.1)", "ujson (>=4.0.1,!=4.0.2,!=4.1.0,!=4.2.0,!=4.3.0,!=5.0.0,!=5.1.0,<6.0.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "h11"
|
||||
@@ -553,17 +553,6 @@ typing-extensions = {version = ">=3.10.0", markers = "python_version < \"3.10\""
|
||||
[package.extras]
|
||||
full = ["itsdangerous", "jinja2", "python-multipart", "pyyaml", "requests"]
|
||||
|
||||
[[package]]
|
||||
name = "starlette-context"
|
||||
version = "0.3.4"
|
||||
description = "Access context in Starlette"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.dependencies]
|
||||
starlette = "*"
|
||||
|
||||
[[package]]
|
||||
name = "tomli"
|
||||
version = "2.0.1"
|
||||
@@ -643,7 +632,7 @@ testing = ["func-timeout", "jaraco.itertools", "pytest (>=6)", "pytest-black (>=
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.7"
|
||||
content-hash = "14ff9c57ca971c645f1a075b5c6fa0a84a38eaf6399d14afa724136728a3da03"
|
||||
content-hash = "b4e980ee90226bab07750b1becc8c69df7752f6d168d200a79c782aa1efe61da"
|
||||
|
||||
[metadata.files]
|
||||
anyio = [
|
||||
@@ -1010,10 +999,6 @@ starlette = [
|
||||
{file = "starlette-0.19.1-py3-none-any.whl", hash = "sha256:5a60c5c2d051f3a8eb546136aa0c9399773a689595e099e0877704d5888279bf"},
|
||||
{file = "starlette-0.19.1.tar.gz", hash = "sha256:c6d21096774ecb9639acad41b86b7706e52ba3bf1dc13ea4ed9ad593d47e24c7"},
|
||||
]
|
||||
starlette-context = [
|
||||
{file = "starlette_context-0.3.4-py37-none-any.whl", hash = "sha256:b16bf17bd3ead7ded2f458aebf7f913744b9cf28305e16c69b435a6c6ddf1135"},
|
||||
{file = "starlette_context-0.3.4.tar.gz", hash = "sha256:2d28e1838302fb5d5adacadc10fb73fb2d5cca1f0aa1e279698701cc96f1567c"},
|
||||
]
|
||||
tomli = [
|
||||
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
|
||||
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
|
||||
|
||||
@@ -22,7 +22,6 @@ bitstring = "^3.1.9"
|
||||
secp256k1 = "^0.14.0"
|
||||
sqlalchemy-aio = "^0.17.0"
|
||||
python-bitcoinlib = "^0.11.2"
|
||||
starlette-context = "^0.3.4"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
black = {version = "^22.8.0", allow-prereleases = true}
|
||||
|
||||
Reference in New Issue
Block a user