nlbone 0.3.1__py3-none-any.whl → 0.3.3__py3-none-any.whl

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.
nlbone/config/settings.py CHANGED
@@ -22,11 +22,21 @@ def _guess_env_file() -> str | None:
22
22
  return str(f)
23
23
 
24
24
 
25
+ def _is_production_env() -> bool:
26
+ raw = os.getenv("NLBONE_ENV") or os.getenv("ENV") or os.getenv("ENVIRONMENT")
27
+ if not raw:
28
+ return False
29
+ return raw.strip().lower() in {"prod", "production"}
30
+
31
+
25
32
  class Settings(BaseSettings):
26
33
  # ---------------------------
27
34
  # App
28
35
  # ---------------------------
29
- ENV: Literal["local", "dev", "staging", "prod"] = Field(default="local")
36
+ PORT: int = 8000
37
+ ENV: Literal["local", "dev", "staging", "prod"] = Field(default="local",
38
+ validation_alias=AliasChoices("NLBONE_ENV", "ENV",
39
+ "ENVIRONMENT"))
30
40
  DEBUG: bool = Field(default=False)
31
41
  LOG_LEVEL: Literal["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"] = Field(default="INFO")
32
42
  LOG_JSON: bool = Field(default=True)
@@ -53,7 +63,9 @@ class Settings(BaseSettings):
53
63
  # ---------------------------
54
64
  # Database
55
65
  # ---------------------------
56
- POSTGRES_DB_DSN: str = Field(default="postgresql+asyncpg://user:pass@localhost:5432/nlbone")
66
+ POSTGRES_DB_DSN: str = Field(default="postgresql+asyncpg://user:pass@localhost:5432/nlbone",
67
+ validation_alias=AliasChoices("NLBONE_POSTGRES_DB_DSN",
68
+ "POSTGRES_DB_DSN", "DATABASE_URL", "DB_DSN"))
57
69
 
58
70
  # ---------------------------
59
71
  # Messaging / Cache
@@ -76,6 +88,12 @@ class Settings(BaseSettings):
76
88
  extra="ignore",
77
89
  )
78
90
 
91
+ @classmethod
92
+ def load(cls, env_file: str | None = None) -> "Settings":
93
+ if _is_production_env():
94
+ return cls()
95
+ return cls(_env_file=env_file or _guess_env_file())
96
+
79
97
 
80
98
  @lru_cache(maxsize=4)
81
99
  def get_settings(env_file: str | None = None) -> Settings:
@@ -85,5 +103,4 @@ def get_settings(env_file: str | None = None) -> Settings:
85
103
  from nlbone.config.settings import get_settings
86
104
  settings = get_settings()
87
105
  """
88
- env_file = env_file or _guess_env_file()
89
- return Settings(_env_file=env_file)
106
+ return Settings.load(env_file)
@@ -1 +1,2 @@
1
- from .db import get_session, get_async_session
1
+ from .db import get_session, get_async_session
2
+ from .auth import has_access, client_has_access, current_client_id, current_user_id, current_request, user_authenticated
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nlbone
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: Backbone package for interfaces and infrastructure in Python projects
5
5
  Author-email: Amir Hosein Kahkbazzadeh <a.khakbazzadeh@gmail.com>
6
6
  License: MIT
@@ -20,7 +20,7 @@ nlbone/adapters/messaging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
20
20
  nlbone/adapters/messaging/redis.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  nlbone/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  nlbone/config/logging.py,sha256=68WRQejEpL6eHEY_cOgdlOjndKc-RWth0n4YmXnceC8,5041
23
- nlbone/config/settings.py,sha256=2PEGXJwmhjHK9wuX2AKCfPZWz3F1dvJ5ig4Sad7jqlc,3274
23
+ nlbone/config/settings.py,sha256=LRKQsBJgTYKiwMt8tv-ipoG6hdBkieXNJZVdPZx6WTQ,4070
24
24
  nlbone/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  nlbone/core/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  nlbone/core/application/services.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -41,7 +41,7 @@ nlbone/interfaces/api/exception_handlers.py,sha256=Z3_dTGAmpHfgaMe_HTW89OpRtq-aa
41
41
  nlbone/interfaces/api/exceptions.py,sha256=uJWNEu5-cgoMedYebNHuIFJioXl_fnBhO89E6FINT2A,2259
42
42
  nlbone/interfaces/api/routers.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  nlbone/interfaces/api/schemas.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
- nlbone/interfaces/api/dependencies/__init__.py,sha256=XrTGkHS8xqryfyr8XSm_s9sIzp4E0b44XQ40sVWcKMY,46
44
+ nlbone/interfaces/api/dependencies/__init__.py,sha256=V9Nf0JcQkJ0FjBYDRyQsJcLQUejZ2pSmmn05hdKgK1Y,167
45
45
  nlbone/interfaces/api/dependencies/auth.py,sha256=GHUlZ5L2N6ilOaOJqRicHrORB3AD3z2Y-qrO9Q2dNr4,1774
46
46
  nlbone/interfaces/api/dependencies/db.py,sha256=IqDVq1lcCCxd22FBUg523lVANM_j71BYAQtsbrHc4M8,465
47
47
  nlbone/interfaces/api/middleware/__init__.py,sha256=Xcxg9Oy8uToPXaTSdBTKhst-hZwsaIEhqxx4mmo1bZI,157
@@ -58,7 +58,7 @@ nlbone/interfaces/jobs/sync_tokens.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
58
58
  nlbone/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
59
  nlbone/utils/context.py,sha256=AUiN1jM0ebNMopZQoJSqWTfUHuVrp-HV8x6g7QsbEJ8,1601
60
60
  nlbone/utils/time.py,sha256=dC0ucyAmHdNf3wpA_JPinl2VJRubWqx2vcRpJsT3-0k,102
61
- nlbone-0.3.1.dist-info/METADATA,sha256=WJBTZ953uoswagIj1JRD-iZnykfYhQqjEFRogKc56ZU,2298
62
- nlbone-0.3.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
63
- nlbone-0.3.1.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
- nlbone-0.3.1.dist-info/RECORD,,
61
+ nlbone-0.3.3.dist-info/METADATA,sha256=OIDeImr67YyFifYgsM-9nrGNFBMoBu_6UQjkdLR6JE0,2298
62
+ nlbone-0.3.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
63
+ nlbone-0.3.3.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
+ nlbone-0.3.3.dist-info/RECORD,,
File without changes