diff --git a/email-proxy/.env-template b/email-proxy/.env-template new file mode 100644 index 0000000..ba723a0 --- /dev/null +++ b/email-proxy/.env-template @@ -0,0 +1,4 @@ +# rename this to .env + +BREVO_API_KEY=brevo_api_key +BREVO_SENDER=proxy@example.com \ No newline at end of file diff --git a/email-proxy/.gitignore b/email-proxy/.gitignore index 1d7b718..26a33e7 100644 --- a/email-proxy/.gitignore +++ b/email-proxy/.gitignore @@ -1 +1,2 @@ +.env hotels.db \ No newline at end of file diff --git a/email-proxy/README b/email-proxy/README index be89326..06ff343 100644 --- a/email-proxy/README +++ b/email-proxy/README @@ -1,3 +1,5 @@ +# TODO bettter move everything to .env and gitignore it + INITIAL SETUP cd email-proxy diff --git a/email-proxy/docker-compose.yml b/email-proxy/docker-compose.yml index ad4c70c..3ee87ef 100644 --- a/email-proxy/docker-compose.yml +++ b/email-proxy/docker-compose.yml @@ -1,11 +1,11 @@ services: email-proxy: - restart: unless-stopped build: . ports: - "8000:8000" volumes: - ./hotels.db:/app/hotels.db environment: - - BREVO_API_KEY= - - BREVO_SENDER= \ No newline at end of file + - BREVO_API_KEY=${BREVO_API_KEY} + - BREVO_SENDER=${BREVO_SENDER} + restart: unless-stopped \ No newline at end of file diff --git a/email-proxy/proxy.py b/email-proxy/proxy.py index 3269158..bf0d704 100644 --- a/email-proxy/proxy.py +++ b/email-proxy/proxy.py @@ -27,7 +27,7 @@ def on_startup(): # --- API Endpoints --- -@app.post("/api/contact") +@app.post("/contact") async def contact(request: Request): data = await request.json() hotel_id = data.get("hotel") @@ -74,4 +74,3 @@ async def send_brevo_email(to_email, from_name, reply_to_email, subject, message ) if r.status_code >= 400: raise HTTPException(status_code=500, detail=f"Email failed: {r.text}") - diff --git a/email-proxy/update.py b/email-proxy/update.py index 13ed7ba..3506f1a 100644 --- a/email-proxy/update.py +++ b/email-proxy/update.py @@ -12,15 +12,15 @@ command = sys.argv[1].lower() if command == "add" and len(sys.argv) == 4: # Run helper.py inside container with add subprocess.run([ - "docker-compose", "run", "--rm", "email-proxy", + "sudo", "docker", "compose", "run", "--rm", "email-proxy", "python", "helper.py", "add", sys.argv[2], sys.argv[3] ]) elif command == "remove" and len(sys.argv) == 3: # Run helper.py inside container with remove subprocess.run([ - "docker-compose", "run", "--rm", "email-proxy", + "sudo", "docker", "compose", "run", "--rm", "email-proxy", "python", "helper.py", "remove", sys.argv[2] ]) else: print("Invalid arguments.") - sys.exit(1) + sys.exit(1) \ No newline at end of file