dwyeapi 0.5.1__tar.gz → 0.5.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/PKG-INFO +1 -1
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/README.md +9 -2
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/pyproject.toml +1 -1
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/__init__.py +1 -1
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/config.py +0 -1
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi.egg-info/PKG-INFO +1 -1
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/tests/test_config.py +3 -2
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/setup.cfg +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/cache.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/database.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/dependencies.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/dt.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/exceptions.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/logger.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/masking.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/pagination.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/__init__.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/email/__init__.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/email/aliyun.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/email/base.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/email/config.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/email/factory.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/email/mock.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/email/protocol.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/email/resend.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/sms/__init__.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/sms/aliyun.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/sms/base.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/sms/config.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/sms/factory.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/sms/mock.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/providers/sms/protocol.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/response.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/security.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/tasks/__init__.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/tasks/context.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/tasks/model.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/tasks/pool.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/tasks/registry.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/tasks/router.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/tasks/schema.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/tasks/service.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi/tasks/worker.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi.egg-info/SOURCES.txt +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi.egg-info/dependency_links.txt +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi.egg-info/requires.txt +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/src/dwyeapi.egg-info/top_level.txt +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/tests/test_cache.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/tests/test_database.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/tests/test_dependencies.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/tests/test_exceptions.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/tests/test_logger.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/tests/test_masking.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/tests/test_pagination.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/tests/test_response.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/tests/test_security.py +0 -0
- {dwyeapi-0.5.1 → dwyeapi-0.5.2}/tests/test_tasks.py +0 -0
|
@@ -23,14 +23,18 @@ pip install dwyeapi
|
|
|
23
23
|
|
|
24
24
|
## Environment (dev / prod)
|
|
25
25
|
|
|
26
|
-
`BaseSettings` 暴露顶层 `environment` 字段,可选值 `"dev" | "prod"`,**默认 `"prod"`**(保守派,误配置时也按 prod 行为)。
|
|
26
|
+
`BaseSettings` 暴露顶层 `environment` 字段,可选值 `"dev" | "prod"`,**默认 `"prod"`**(保守派,误配置时也按 prod 行为)。eapi **不再提供 `debug` 字段** —— 所有"调试开关"统一判断 `is_dev()`,避免两个维度互相冲突。
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
29
|
# .env
|
|
30
30
|
ENVIRONMENT=dev # 开发环境;留空或 prod 即生产
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
业务代码通过 `dwyeapi.is_dev()` / `dwyeapi.is_prod()` / `dwyeapi.get_environment()`
|
|
33
|
+
业务代码通过 `dwyeapi.is_dev()` / `dwyeapi.is_prod()` / `dwyeapi.get_environment()` 读当前环境。
|
|
34
|
+
|
|
35
|
+
### FastAPI docs/redoc/openapi 仅 dev 暴露
|
|
36
|
+
|
|
37
|
+
非 dev 环境必须关闭 Swagger/ReDoc/OpenAPI schema 三个端点,避免线上暴露路由和字段元信息:
|
|
34
38
|
|
|
35
39
|
```python
|
|
36
40
|
from dwyeapi import is_dev
|
|
@@ -45,6 +49,9 @@ app = FastAPI(
|
|
|
45
49
|
redoc_url="/redoc" if is_dev() else None,
|
|
46
50
|
openapi_url="/openapi.json" if is_dev() else None,
|
|
47
51
|
)
|
|
52
|
+
|
|
53
|
+
# SQL echo、慢路由 profiling、中间件堆栈打印等调试性质开关也统一用 is_dev() 守护
|
|
54
|
+
engine = create_async_engine_factory(settings.database_url, echo=is_dev())
|
|
48
55
|
```
|
|
49
56
|
|
|
50
57
|
### Mock provider 仅 dev 可用
|
|
@@ -53,7 +53,6 @@ class BaseSettings(PydanticBaseSettings):
|
|
|
53
53
|
jwt_algorithm: str = "HS256"
|
|
54
54
|
access_token_expire_minutes: int = 30
|
|
55
55
|
environment: Environment = "prod"
|
|
56
|
-
debug: bool = False
|
|
57
56
|
allowed_origins: list[str] = Field(default_factory=list)
|
|
58
57
|
|
|
59
58
|
# Task module settings (task_ prefix)
|
|
@@ -29,12 +29,13 @@ class TestBaseSettings:
|
|
|
29
29
|
assert s.redis_url == "redis://localhost:6379/0"
|
|
30
30
|
assert s.secret_key == "test-secret"
|
|
31
31
|
|
|
32
|
-
def
|
|
32
|
+
def test_debug_field_removed(self, monkeypatch):
|
|
33
|
+
"""debug 字段已废弃,请用 environment + is_dev()/is_prod() 代替。"""
|
|
33
34
|
monkeypatch.setenv("DATABASE_URL", "postgresql+asyncpg://u:p@localhost/db")
|
|
34
35
|
monkeypatch.setenv("REDIS_URL", "redis://localhost:6379/0")
|
|
35
36
|
monkeypatch.setenv("SECRET_KEY", "s")
|
|
36
37
|
s = BaseSettings()
|
|
37
|
-
assert s
|
|
38
|
+
assert not hasattr(s, "debug")
|
|
38
39
|
|
|
39
40
|
def test_allowed_origins_defaults_empty(self, monkeypatch):
|
|
40
41
|
monkeypatch.setenv("DATABASE_URL", "postgresql+asyncpg://u:p@localhost/db")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|