15
15
from tipg .errors import DEFAULT_STATUS_CODES , add_exception_handlers
16
16
from tipg .factory import Endpoints as TiPgEndpoints
17
17
from tipg .middleware import CacheControlMiddleware , CatalogUpdateMiddleware
18
+ from tipg .settings import DatabaseSettings
18
19
19
20
from . import __version__ as eoapi_vector_version
20
21
from .config import ApiSettings , PostgresSettings
24
25
25
26
settings = ApiSettings ()
26
27
auth_settings = OpenIdConnectSettings ()
28
+ db_settings = DatabaseSettings (
29
+ # For the Tables' Catalog we only use the `public` schema
30
+ schemas = ["public" ],
31
+ # We exclude public functions
32
+ exclude_function_schemas = ["public" ],
33
+ # We allow non-spatial tables
34
+ spatial = False ,
35
+ )
36
+
27
37
28
38
# Logs
29
- init_logging (
30
- debug = settings .debug ,
31
- loggers = {
32
- "botocore.credentials" : {
33
- "level" : "CRITICAL" ,
34
- "propagate" : False ,
35
- },
36
- "botocore.utils" : {
37
- "level" : "CRITICAL" ,
38
- "propagate" : False ,
39
- },
40
- "rio-tiler" : {
41
- "level" : "ERROR" ,
42
- "propagate" : False ,
43
- },
44
- },
45
- )
39
+ init_logging (debug = settings .debug )
46
40
logger = logging .getLogger (__name__ )
47
41
48
42
@@ -52,22 +46,14 @@ async def lifespan(app: FastAPI):
52
46
logger .debug ("Connecting to db..." )
53
47
await connect_to_db (
54
48
app ,
55
- settings = PostgresSettings (),
56
49
# We enable both pgstac and public schemas (pgstac will be used by custom functions)
57
50
schemas = ["pgstac" , "public" ],
58
51
user_sql_files = list (CUSTOM_SQL_DIRECTORY .glob ("*.sql" )), # type: ignore
52
+ settings = PostgresSettings (),
59
53
)
60
54
61
55
logger .debug ("Registering collection catalog..." )
62
- await register_collection_catalog (
63
- app ,
64
- # For the Tables' Catalog we only use the `public` schema
65
- schemas = ["public" ],
66
- # We exclude public functions
67
- exclude_function_schemas = ["public" ],
68
- # We allow non-spatial tables
69
- spatial = False ,
70
- )
56
+ await register_collection_catalog (app , db_settings = db_settings )
71
57
72
58
yield
73
59
@@ -126,9 +112,7 @@ async def lifespan(app: FastAPI):
126
112
CatalogUpdateMiddleware ,
127
113
func = register_collection_catalog ,
128
114
ttl = settings .catalog_ttl ,
129
- schemas = ["public" ],
130
- exclude_function_schemas = ["public" ],
131
- spatial = False ,
115
+ db_settings = db_settings ,
132
116
)
133
117
134
118
add_exception_handlers (app , DEFAULT_STATUS_CODES )
@@ -143,7 +127,17 @@ async def lifespan(app: FastAPI):
143
127
)
144
128
def ping ():
145
129
"""Health check."""
146
- return {"ping" : "pong!" }
130
+ from pyproj import __proj_version__ as proj_version # noqa
131
+ from pyproj import __version__ as pyproj_version # noqa
132
+ from tipg import __version__ as tipg_version # noqa
133
+
134
+ return {
135
+ "versions" : {
136
+ "tipg" : tipg_version ,
137
+ "proj" : proj_version ,
138
+ "pyproj" : pyproj_version ,
139
+ },
140
+ }
147
141
148
142
149
143
if settings .debug :
@@ -156,16 +150,7 @@ async def raw_catalog(request: Request):
156
150
@app .get ("/refresh" , include_in_schema = False )
157
151
async def refresh (request : Request ):
158
152
"""Return parsed catalog data for testing."""
159
- await register_collection_catalog (
160
- request .app ,
161
- # For the Tables' Catalog we only use the `public` schema
162
- schemas = ["public" ],
163
- # We exclude public functions
164
- exclude_function_schemas = ["public" ],
165
- # We allow non-spatial tables
166
- spatial = False ,
167
- )
168
-
153
+ await register_collection_catalog (request .app , db_settings = db_settings )
169
154
return request .app .state .collection_catalog
170
155
171
156
0 commit comments