From 9c7f378b79160cc3100db0d2f673cb1a67fca1aa Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 6 Mar 2024 14:26:05 +0100 Subject: [PATCH] Add dependency on imgproxy service and update version --- docker-compose.yaml | 3 +++ index.js | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index f1f44e5..51587b6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -12,6 +12,9 @@ services: interval: 2s timeout: 10s retries: 5 + depends_on: + imgproxy: + condition: service_healthy imgproxy: image: darthsim/imgproxy environment: diff --git a/index.js b/index.js index 976d764..677aa2a 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,19 @@ -const allowedDomains = process.env.ALLOWED_REMOTE_DOMAINS.split(",") || ["*"]; -const imgproxyUrl = process.env.IMGPROXY_URL || "http://imgproxy:8080"; - +const allowedDomains = process?.env?.ALLOWED_REMOTE_DOMAINS.split(",") || ["*"]; +const imgproxyUrl = process?.env?.IMGPROXY_URL || "http://imgproxy:8080"; +const version = "0.0.2" Bun.serve({ port: 3000, async fetch(req) { const url = new URL(req.url); + if (url.pathname === "/") { + return new Response(`

Next Image Transformation v${version}

More info https://github.com/coollabsio/next-image-transformation.`, { + headers: { + "Content-Type": "text/html", + }, + }); + } + + if (url.pathname === "/health") { return new Response("OK"); };