1515from tipg .errors import DEFAULT_STATUS_CODES , add_exception_handlers
1616from tipg .factory import Endpoints as TiPgEndpoints
1717from tipg .middleware import CacheControlMiddleware , CatalogUpdateMiddleware
18+ from tipg .settings import DatabaseSettings
1819
1920from . import __version__ as eoapi_vector_version
2021from .config import ApiSettings , PostgresSettings
2425
2526settings = ApiSettings ()
2627auth_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+
2737
2838# 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 )
4640logger = logging .getLogger (__name__ )
4741
4842
@@ -52,22 +46,14 @@ async def lifespan(app: FastAPI):
5246 logger .debug ("Connecting to db..." )
5347 await connect_to_db (
5448 app ,
55- settings = PostgresSettings (),
5649 # We enable both pgstac and public schemas (pgstac will be used by custom functions)
5750 schemas = ["pgstac" , "public" ],
5851 user_sql_files = list (CUSTOM_SQL_DIRECTORY .glob ("*.sql" )), # type: ignore
52+ settings = PostgresSettings (),
5953 )
6054
6155 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 )
7157
7258 yield
7359
@@ -126,9 +112,7 @@ async def lifespan(app: FastAPI):
126112 CatalogUpdateMiddleware ,
127113 func = register_collection_catalog ,
128114 ttl = settings .catalog_ttl ,
129- schemas = ["public" ],
130- exclude_function_schemas = ["public" ],
131- spatial = False ,
115+ db_settings = db_settings ,
132116 )
133117
134118add_exception_handlers (app , DEFAULT_STATUS_CODES )
@@ -143,7 +127,17 @@ async def lifespan(app: FastAPI):
143127)
144128def ping ():
145129 """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+ }
147141
148142
149143if settings .debug :
@@ -156,16 +150,7 @@ async def raw_catalog(request: Request):
156150 @app .get ("/refresh" , include_in_schema = False )
157151 async def refresh (request : Request ):
158152 """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 )
169154 return request .app .state .collection_catalog
170155
171156
0 commit comments