From 477a0dd2b191846320a413e66ed2c5f62f9240db Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Jul 2025 21:28:21 +0000 Subject: [PATCH 1/3] chore(deps): bump on-headers and morgan Bumps [on-headers](https://github.com/jshttp/on-headers) to 1.1.0 and updates ancestor dependency [morgan](https://github.com/expressjs/morgan). These dependencies need to be updated together. Updates `on-headers` from 1.0.2 to 1.1.0 - [Release notes](https://github.com/jshttp/on-headers/releases) - [Changelog](https://github.com/jshttp/on-headers/blob/master/HISTORY.md) - [Commits](https://github.com/jshttp/on-headers/compare/v1.0.2...v1.1.0) Updates `morgan` from 1.10.0 to 1.10.1 - [Release notes](https://github.com/expressjs/morgan/releases) - [Changelog](https://github.com/expressjs/morgan/blob/master/HISTORY.md) - [Commits](https://github.com/expressjs/morgan/compare/1.10.0...1.10.1) --- updated-dependencies: - dependency-name: on-headers dependency-version: 1.1.0 dependency-type: indirect - dependency-name: morgan dependency-version: 1.10.1 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- package-lock.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index dd112f3..79e3730 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8137,16 +8137,16 @@ } }, "node_modules/morgan": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz", - "integrity": "sha512-AbegBVI4sh6El+1gNwvD5YIck7nSA36weD7xvIxG4in80j/UoK8AEGaWnnz8v1GxonMCltmlNs5ZKbGvl9b1XQ==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.1.tgz", + "integrity": "sha512-223dMRJtI/l25dJKWpgij2cMtywuG/WiUKXdvwfbhGKBhy1puASqXwFzmWZ7+K73vUPoR7SS2Qz2cI/g9MKw0A==", "license": "MIT", "dependencies": { "basic-auth": "~2.0.1", "debug": "2.6.9", "depd": "~2.0.0", "on-finished": "~2.3.0", - "on-headers": "~1.0.2" + "on-headers": "~1.1.0" }, "engines": { "node": ">= 0.8.0" @@ -8560,9 +8560,9 @@ } }, "node_modules/on-headers": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", - "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.1.0.tgz", + "integrity": "sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A==", "license": "MIT", "engines": { "node": ">= 0.8" From ab80f48ddedb8e78f2e8ec05859c3bd64ca1305e Mon Sep 17 00:00:00 2001 From: William Oldham Date: Sun, 5 Oct 2025 19:48:02 +0100 Subject: [PATCH 2/3] chore: add logging to ip2location and add token to build scripts --- .github/workflows/docker.yml | 2 ++ Dockerfile | 3 ++- package.json | 5 +++-- scripts/download-ip2location-databases.js | 5 ++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2691cb2..58d7eb6 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -53,6 +53,8 @@ jobs: push: ${{ env.SHOULD_PUSH_IMAGE }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + secrets: | + "ip2location-token=${{ secrets.IP2LOCATION_TOKEN }}" cache-from: type=gha cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index 53811ab..4e48ff4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,8 +27,9 @@ RUN --mount=type=bind,source=package.json,target=package.json \ npm ci COPY . . -RUN npm run build +RUN --mount=type=secret,id=ip2location-token,env=PN_ACT_CONFIG_IP2LOCATION_TOKEN \ + npm run build # * Running the final application FROM base AS final diff --git a/package.json b/package.json index e8e6ba8..7d0c32b 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "lint": "eslint .", "lint:fix": "eslint --fix .", - "build": "npm run lint && npm run clean && npx tsc && npx tsc-alias && npm run copy-static && node ./scripts/download-ip2location-databases.js", + "download-geoip-db": "node ./scripts/download-ip2location-databases.js", + "build": "npm run lint && npm run clean && npx tsc && npx tsc-alias && npm run copy-static && npm run download-geoip-db", "clean": "rimraf ./dist", "copy-static": "copyfiles -e \"src/**/*.ts\" -u 1 \"src/**/*\" dist", "start": "node .", @@ -87,4 +88,4 @@ "ndarray": "^1.0.19", "typescript": "^4.9.5" } -} +} \ No newline at end of file diff --git a/scripts/download-ip2location-databases.js b/scripts/download-ip2location-databases.js index 4a01a97..3a45616 100644 --- a/scripts/download-ip2location-databases.js +++ b/scripts/download-ip2location-databases.js @@ -18,12 +18,15 @@ const databases = { async function main() { if (!process.env.PN_ACT_CONFIG_IP2LOCATION_TOKEN) { - // * Optional + console.warn('IP2Location token not found in environment variables. Skipping database download.'); return; } + console.log(`Downloading ${Object.keys(databases).length} IP2Location databases...`); + for (const name in databases) { const database = databases[name]; + console.log(`Downloading ${database.file_name}...`); const response = await fetch(`https://www.ip2location.com/download/?token=${process.env.PN_ACT_CONFIG_IP2LOCATION_TOKEN}&file=${name}`); const arrayBuffer = await response.arrayBuffer(); const buffer = Buffer.from(arrayBuffer); From 5697a9e73fa41c27d74300520ebeae7aad5a5487 Mon Sep 17 00:00:00 2001 From: William Oldham Date: Sun, 5 Oct 2025 19:50:12 +0100 Subject: [PATCH 3/3] chore: add ip2location token for both platforms --- .github/workflows/docker.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 58d7eb6..34ca976 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -99,5 +99,7 @@ jobs: push: ${{ env.SHOULD_PUSH_IMAGE }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + secrets: | + "ip2location-token=${{ secrets.IP2LOCATION_TOKEN }}" cache-from: type=gha cache-to: type=gha,mode=max