♻️(backend) generalize YProvider API config

Abstracted base URL and API key under 'y-provider' for
reuse in future endpoints, aligning with microservice naming.

Please note the YProvider API here is internal to the cluster.
In facts, we don't want these endpoints to be exposed by any ingress
This commit is contained in:
lebaudantoine
2024-12-15 18:31:43 +01:00
committed by aleb_the_flash
parent ba63358098
commit c10808b611
4 changed files with 22 additions and 13 deletions

View File

@@ -31,7 +31,7 @@ class YdocConverter:
@property
def auth_header(self):
"""Build microservice authentication header."""
return settings.CONVERSION_API_KEY
return settings.Y_PROVIDER_API_KEY
def convert_markdown(self, text):
"""Convert a Markdown text into our internal format using an external microservice."""
@@ -41,7 +41,7 @@ class YdocConverter:
try:
response = requests.post(
settings.CONVERSION_API_URL,
f"{settings.Y_PROVIDER_API_BASE_URL}{settings.CONVERSION_API_ENDPOINT}/",
json={
"content": text,
},