costvine-startup 0.1.78__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.
@@ -0,0 +1,3 @@
1
+ """Server function startup routines."""
2
+
3
+ from .main import *
@@ -0,0 +1,60 @@
1
+ import json
2
+ import os
3
+ from dataclasses import dataclass
4
+ from typing import Any, Dict, cast
5
+
6
+ import firebase_admin
7
+ from firebase_admin import App, auth, firestore
8
+ from google.cloud.firestore import Client
9
+
10
+ GlobalConfig = Dict[str, Any]
11
+
12
+
13
+ @dataclass
14
+ class StartupConfig:
15
+ global_config: GlobalConfig
16
+ app: App
17
+ auth: Any # firebase_admin.auth module (acts as the Auth client)
18
+ firestore: Client
19
+
20
+
21
+ def _get_app() -> App:
22
+ try:
23
+ return firebase_admin.get_app()
24
+ except ValueError:
25
+ return firebase_admin.initialize_app()
26
+
27
+
28
+ def startup(app_config: GlobalConfig) -> StartupConfig:
29
+ app = _get_app()
30
+ cfg = StartupConfig(
31
+ global_config=app_config,
32
+ app=app,
33
+ auth=auth,
34
+ firestore=firestore.client(app, app_config.get("database")),
35
+ )
36
+ print("startup-server/startup: Initialized for database:", cfg.global_config.get("database"))
37
+ return cfg
38
+
39
+
40
+ def _load_config() -> GlobalConfig:
41
+ config_path = os.path.abspath("config.json")
42
+
43
+ try:
44
+ with open(config_path, encoding="utf-8") as f:
45
+ raw = f.read()
46
+ except OSError as e:
47
+ raise RuntimeError(f"Failed to read config file at {config_path}: {e}") from e
48
+
49
+ try:
50
+ config = json.loads(raw)
51
+ except json.JSONDecodeError as e:
52
+ raise RuntimeError(f"Failed to parse config file at {config_path}: {e}") from e
53
+
54
+ if not isinstance(config, dict):
55
+ raise RuntimeError(f"Failed to parse config file at {config_path}: expected a JSON object")
56
+
57
+ return cast(GlobalConfig, config)
58
+
59
+
60
+ startup_config: StartupConfig = startup(_load_config())
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.4
2
+ Name: costvine-startup
3
+ Version: 0.1.78
4
+ Summary: Costvine server function startup routines
5
+ Author: John D. Underhill
6
+ Author-email: junderhill@qisproject.com
7
+ Requires-Python: >=3.12,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Programming Language :: Python :: 3.13
11
+ Classifier: Programming Language :: Python :: 3.14
12
+ Requires-Dist: firebase-admin
13
+ Requires-Dist: google-cloud-firestore
14
+ Description-Content-Type: text/markdown
15
+
16
+ Costvine server function startup routines
17
+
@@ -0,0 +1,6 @@
1
+ costvine_startup/__init__.py,sha256=9bg70enc4Fi0i3TXPrMvM9QKFQkKJYiKqafNXfUOMCI,61
2
+ costvine_startup/main.py,sha256=VOF5_d_8fwsJjtMWJtNclf1nU5dmaM0aXj4R-2asYS4,1607
3
+ costvine_startup/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
+ costvine_startup-0.1.78.dist-info/METADATA,sha256=qoL5diqdDHKisAZI68kqK8y_YnSTSWT1UxbUz7DnMOI,560
5
+ costvine_startup-0.1.78.dist-info/WHEEL,sha256=Vz2fHgx6HFtSwhs8KvkHLqH5Ea4w1_rner5uNVGCeIE,88
6
+ costvine_startup-0.1.78.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.3.2
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any