From a798a22626e9c8679f1e9999d9c94d3385dc51c0 Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Fri, 20 Jun 2025 08:14:46 -0500 Subject: [PATCH 01/18] Updating dev-build workflow to not rely on github secrets but instead to generate its own ssl certificate for testing. --- .github/workflows/dev-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index d724294..0d9da00 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -16,8 +16,8 @@ jobs: - name: Create SSL certificate and key run: | mkdir -p ./ssl/private - echo "${{ secrets.TEST_SSL_KEY }}" > ./ssl/private/secret.key - echo "${{ secrets.TEST_SSL_CERT }}" > ./ssl/private/cert.cer + openssl genrsa -out ./ssl/private/secret.key 2048 + openssl req -new -x509 -key ./ssl/private/secret.key -out ./ssl/private/cert.cer -days 365 -subj "/CN=contoso.com" - name: Create .env file run: | From 83388bb8cb7258a4be496d4ec533660bb936acba Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Fri, 20 Jun 2025 08:51:49 -0500 Subject: [PATCH 02/18] Pushing updated tags for images and updating release build workflow --- .github/workflows/dev-build.yml | 10 +++++++--- .github/workflows/release-build.yml | 15 +++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index 0d9da00..a0bf4e4 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -17,7 +17,7 @@ jobs: run: | mkdir -p ./ssl/private openssl genrsa -out ./ssl/private/secret.key 2048 - openssl req -new -x509 -key ./ssl/private/secret.key -out ./ssl/private/cert.cer -days 365 -subj "/CN=contoso.com" + openssl req -new -x509 -key ./ssl/private/secret.key -out ./ssl/private/cert.cer -days 30 -subj "/CN=contoso.com" - name: Create .env file run: | @@ -94,13 +94,17 @@ jobs: id: org-name run: echo "ORG_LC=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + + - name: Set Timestamp for use in image tag + run: echo "IMAGE_TAG=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV + - name: Build Docker image run: | - docker build -t ghcr.io/${{ env.ORG_LC }}/headers-app:latest-dev . + docker build -t ghcr.io/${{ env.ORG_LC }}/headers-app:${{ env.IMAGE_TAG }}-latest-dev . - name: Log in to GitHub Container Registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - name: Push Docker image run: | - docker push ghcr.io/${{ env.ORG_LC }}/headers-app:latest-dev + docker push ghcr.io/${{ env.ORG_LC }}/headers-app:${{ env.IMAGE_TAG }}-latest-dev diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 9b2b15c..3bd0b44 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -17,8 +17,8 @@ jobs: - name: Create SSL certificate and key run: | mkdir -p ./ssl/private - echo "${{ secrets.TEST_SSL_KEY }}" > ./ssl/private/secret.key - echo "${{ secrets.TEST_SSL_CERT }}" > ./ssl/private/cert.cer + openssl genrsa -out ./ssl/private/secret.key 2048 + openssl req -new -x509 -key ./ssl/private/secret.key -out ./ssl/private/cert.cer -days 30 -subj "/CN=contoso.com" - name: Create .env file run: | @@ -101,14 +101,21 @@ jobs: id: org-name run: echo "ORG_LC=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV + - name: Set lower case release version + id: release_version + run: echo "release_version=$(echo ${{ github.ref_name }} | tr '[:upper:]' '[:lower;]')" >> $GITHUB_ENV + - name: Build Docker image run: | - docker build -t ghcr.io/${{ env.ORG_LC }}/headers-app:latest-dev . + docker build -t ghcr.io/${{ env.ORG_LC }}/headers-app:latest -t ghcr.io/${{ env.ORG_LC }}/headers-app:${{ env.release_version }} . - name: Log in to GitHub Container Registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - name: Push Docker image run: | - docker push ghcr.io/${{ env.ORG_LC }}/headers-app:latest-dev + docker push ghcr.io/${{ env.ORG_LC }}/headers-app:latest + - name: Push Docker image + run: | + docker push ghcr.io/${{ env.ORG_LC }}/headers-app:${{ env.release_version }} From 53ac120d3d80aea02746fbd54025b262d1ee46a0 Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Fri, 20 Jun 2025 08:57:06 -0500 Subject: [PATCH 03/18] adding vailure verbosity to github actions --- .github/workflows/dev-build.yml | 4 ++++ .github/workflows/release-build.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index a0bf4e4..5510c28 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -51,6 +51,8 @@ jobs: EXPECTED_RESPONSE='{"method":"POST","url":"/","clientIP":"::1","headers":{"host":"localhost:8443","user-agent":"curl/8.5.0","accept":"*/*","content-type":"application/json","content-length":"27"}}' if [ "$RESPONSE" != "$EXPECTED_RESPONSE" ]; then echo "Test failed: Response does not match POST" + echo "Expected: $EXPECTED_RESPONSE" + echo "Got: $RESPONSE" exit 1 fi @@ -82,6 +84,8 @@ jobs: EXPECTED_RESPONSE='{"method":"POST","url":"/","clientIP":"::1","headers":{"host":"localhost:8080","user-agent":"curl/8.5.0","accept":"*/*","content-type":"application/json","content-length":"27"}}' if [ "$RESPONSE" != "$EXPECTED_RESPONSE" ]; then echo "Test failed: Response does not match POST body (No SSL)" + echo "Expected: $EXPECTED_RESPONSE" + echo "Got: $RESPONSE" exit 1 fi diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 3bd0b44..b8a8c99 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -52,6 +52,8 @@ jobs: EXPECTED_RESPONSE='{"method":"POST","url":"/","clientIP":"::1","headers":{"host":"localhost","user-agent":"curl/8.5.0","accept":"*/*","content-type":"application/json","content-length":"27"}}' if [ "$RESPONSE" != "$EXPECTED_RESPONSE" ]; then echo "Test failed: Response does not match POST body" + echo "Expected: $EXPECTED_RESPONSE" + echo "Got: $RESPONSE" exit 1 fi @@ -83,6 +85,8 @@ jobs: EXPECTED_RESPONSE='{"method":"POST","url":"/","clientIP":"::1","headers":{"host":"localhost:8080","user-agent":"curl/8.5.0","accept":"*/*","content-type":"application/json","content-length":"27"}}' if [ "$RESPONSE" != "$EXPECTED_RESPONSE" ]; then echo "Test failed: Response does not match POST body (No SSL)" + echo "Expected: $EXPECTED_RESPONSE" + echo "Got: $RESPONSE" exit 1 fi From 124952ec0e70d91c9124652e859912f594e400ab Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Fri, 20 Jun 2025 11:48:36 -0500 Subject: [PATCH 04/18] Fixing typo in release build workflow --- .github/workflows/release-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index b8a8c99..b87d8d1 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -82,7 +82,7 @@ jobs: -H "Content-Type: application/json" \ --data "$POST_BODY") echo "Response: $RESPONSE" - EXPECTED_RESPONSE='{"method":"POST","url":"/","clientIP":"::1","headers":{"host":"localhost:8080","user-agent":"curl/8.5.0","accept":"*/*","content-type":"application/json","content-length":"27"}}' + EXPECTED_RESPONSE='{"method":"POST","url":"/","clientIP":"::1","headers":{"host":"localhost:8443","user-agent":"curl/8.5.0","accept":"*/*","content-type":"application/json","content-length":"27"}}' if [ "$RESPONSE" != "$EXPECTED_RESPONSE" ]; then echo "Test failed: Response does not match POST body (No SSL)" echo "Expected: $EXPECTED_RESPONSE" From 743f3921645d2f31641d11d7c8b5629e5b363977 Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Fri, 20 Jun 2025 13:47:44 -0500 Subject: [PATCH 05/18] correcting typo in release build workflow --- .github/workflows/release-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index b87d8d1..04f1a27 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -49,7 +49,7 @@ jobs: -H "Content-Type: application/json" \ --data "$POST_BODY") echo "Response: $RESPONSE" - EXPECTED_RESPONSE='{"method":"POST","url":"/","clientIP":"::1","headers":{"host":"localhost","user-agent":"curl/8.5.0","accept":"*/*","content-type":"application/json","content-length":"27"}}' + EXPECTED_RESPONSE='{"method":"POST","url":"/","clientIP":"::1","headers":{"host":"localhos:8443","user-agent":"curl/8.5.0","accept":"*/*","content-type":"application/json","content-length":"27"}}' if [ "$RESPONSE" != "$EXPECTED_RESPONSE" ]; then echo "Test failed: Response does not match POST body" echo "Expected: $EXPECTED_RESPONSE" @@ -82,7 +82,7 @@ jobs: -H "Content-Type: application/json" \ --data "$POST_BODY") echo "Response: $RESPONSE" - EXPECTED_RESPONSE='{"method":"POST","url":"/","clientIP":"::1","headers":{"host":"localhost:8443","user-agent":"curl/8.5.0","accept":"*/*","content-type":"application/json","content-length":"27"}}' + EXPECTED_RESPONSE='{"method":"POST","url":"/","clientIP":"::1","headers":{"host":"localhost:8080","user-agent":"curl/8.5.0","accept":"*/*","content-type":"application/json","content-length":"27"}}' if [ "$RESPONSE" != "$EXPECTED_RESPONSE" ]; then echo "Test failed: Response does not match POST body (No SSL)" echo "Expected: $EXPECTED_RESPONSE" From 1f3d25f99390f6b7899bc7c64b7eb03f4c08cef9 Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Fri, 20 Jun 2025 13:54:24 -0500 Subject: [PATCH 06/18] pushing typo correction --- .github/workflows/release-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 04f1a27..2ecf81f 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -49,7 +49,7 @@ jobs: -H "Content-Type: application/json" \ --data "$POST_BODY") echo "Response: $RESPONSE" - EXPECTED_RESPONSE='{"method":"POST","url":"/","clientIP":"::1","headers":{"host":"localhos:8443","user-agent":"curl/8.5.0","accept":"*/*","content-type":"application/json","content-length":"27"}}' + EXPECTED_RESPONSE='{"method":"POST","url":"/","clientIP":"::1","headers":{"host":"localhost:8443","user-agent":"curl/8.5.0","accept":"*/*","content-type":"application/json","content-length":"27"}}' if [ "$RESPONSE" != "$EXPECTED_RESPONSE" ]; then echo "Test failed: Response does not match POST body" echo "Expected: $EXPECTED_RESPONSE" From aecde2d9f2139ff80bac6696f057bcf0af475790 Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Fri, 20 Jun 2025 13:58:39 -0500 Subject: [PATCH 07/18] removing bad code block --- .github/workflows/release-build.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 2ecf81f..588651c 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -95,12 +95,6 @@ jobs: kill $(cat app.pid) || true # Kill the application using the saved PID rm -f app.pid # Clean up the PID file - - name: Build the application - run: npm run build - - - name: List build artifacts - run: ls -la ./build - - name: Set lower case org name id: org-name run: echo "ORG_LC=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV From 2d062f79e97aebe401f92c8c0ec8acf8ea881ba2 Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Fri, 20 Jun 2025 14:04:06 -0500 Subject: [PATCH 08/18] updating container tags --- .github/workflows/release-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 588651c..2a775c9 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -112,8 +112,8 @@ jobs: - name: Push Docker image run: | - docker push ghcr.io/${{ env.ORG_LC }}/headers-app:latest + docker push ghcr.io/${{ env.ORG_LC }}/headers-app:${{ env.release_version }} - name: Push Docker image run: | - docker push ghcr.io/${{ env.ORG_LC }}/headers-app:${{ env.release_version }} + docker push ghcr.io/${{ env.ORG_LC }}/headers-app:prod-latest \ No newline at end of file From fa465c3da56413b73c32b5c86124a97baac64c88 Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Fri, 20 Jun 2025 15:16:41 -0500 Subject: [PATCH 09/18] updating tags to final syntax --- .github/workflows/release-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 2a775c9..227f59f 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -105,14 +105,14 @@ jobs: - name: Build Docker image run: | - docker build -t ghcr.io/${{ env.ORG_LC }}/headers-app:latest -t ghcr.io/${{ env.ORG_LC }}/headers-app:${{ env.release_version }} . + docker build -t ghcr.io/${{ env.ORG_LC }}/headers-app:prod-latest -t ghcr.io/${{ env.ORG_LC }}/headers-app:prod-${{ env.release_version }} . - name: Log in to GitHub Container Registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - name: Push Docker image run: | - docker push ghcr.io/${{ env.ORG_LC }}/headers-app:${{ env.release_version }} + docker push ghcr.io/${{ env.ORG_LC }}/headers-app:prod-${{ env.release_version }} - name: Push Docker image run: | From 1d4da48f50fbc8714a64cf7e036916dba07c8b27 Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Fri, 20 Jun 2025 15:22:56 -0500 Subject: [PATCH 10/18] updating release build workflow --- .github/workflows/release-build.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 227f59f..970e1e1 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -105,15 +105,19 @@ jobs: - name: Build Docker image run: | - docker build -t ghcr.io/${{ env.ORG_LC }}/headers-app:prod-latest -t ghcr.io/${{ env.ORG_LC }}/headers-app:prod-${{ env.release_version }} . + docker build -t ghcr.io/${{ env.ORG_LC }}/headers-app:prod-latest -t ghcr.io/${{ env.ORG_LC }}/headers-app:prod-${{ env.release_version }} -t ghcr.io/${{ env.ORG_LC }}/headers-app:lates . - name: Log in to GitHub Container Registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - name: Push Docker image + - name: Push Specific version Prod Docker image run: | docker push ghcr.io/${{ env.ORG_LC }}/headers-app:prod-${{ env.release_version }} - - name: Push Docker image + - name: Push Prod-Latest Docker image run: | - docker push ghcr.io/${{ env.ORG_LC }}/headers-app:prod-latest \ No newline at end of file + docker push ghcr.io/${{ env.ORG_LC }}/headers-app:prod-latest + + - name: Push latest Docker image + run: | + docker push ghcr.io/${{ env.ORG_LC }}/headers-app:lates \ No newline at end of file From e3a652297b75b2e953f5bb79ecad7d89a934e342 Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Mon, 23 Jun 2025 09:40:51 -0500 Subject: [PATCH 11/18] correcting typos in release-build.yml --- .github/workflows/release-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 970e1e1..27e4fad 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -101,7 +101,7 @@ jobs: - name: Set lower case release version id: release_version - run: echo "release_version=$(echo ${{ github.ref_name }} | tr '[:upper:]' '[:lower;]')" >> $GITHUB_ENV + run: echo "release_version=$(echo ${{ github.ref_name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV - name: Build Docker image run: | @@ -120,4 +120,4 @@ jobs: - name: Push latest Docker image run: | - docker push ghcr.io/${{ env.ORG_LC }}/headers-app:lates \ No newline at end of file + docker push ghcr.io/${{ env.ORG_LC }}/headers-app:latest \ No newline at end of file From ea052911be152cdbb4380277907c18a258ce8967 Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Mon, 23 Jun 2025 09:47:00 -0500 Subject: [PATCH 12/18] adding missing character in docker tag --- .github/workflows/release-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 27e4fad..f085faf 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -105,7 +105,7 @@ jobs: - name: Build Docker image run: | - docker build -t ghcr.io/${{ env.ORG_LC }}/headers-app:prod-latest -t ghcr.io/${{ env.ORG_LC }}/headers-app:prod-${{ env.release_version }} -t ghcr.io/${{ env.ORG_LC }}/headers-app:lates . + docker build -t ghcr.io/${{ env.ORG_LC }}/headers-app:prod-latest -t ghcr.io/${{ env.ORG_LC }}/headers-app:prod-${{ env.release_version }} -t ghcr.io/${{ env.ORG_LC }}/headers-app:latest . - name: Log in to GitHub Container Registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin From bf4e78ac833e5f640d0126932a9e2d4c99d4bce8 Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Fri, 11 Jul 2025 16:22:32 -0500 Subject: [PATCH 13/18] Updating documentation and adding debug functionality to the application. --- .gitignore | 6 ++++++ README.md | 24 ++++++++++++++++++++++++ index.js | 48 +++++++++++++++++++++--------------------------- 3 files changed, 51 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index bcbfe97..a029e35 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,9 @@ dist .yarn/build-state.yml .yarn/install-state.gz .pnp.* + +# Ignore npm executable folders +node_modules/ + +# Ignore local package-lock files +package-lock.json \ No newline at end of file diff --git a/README.md b/README.md index 75bac81..fdf2f0c 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,30 @@ HeaderApp is a Node.js application that mirrors all request headers sent to it. 6. The application will be running on [http://localhost:8080](http://localhost:8080) and [https://localhost:8443](https://localhost:8443). +## Environment configuration options + +Headerapp uses a .ENV file to house configurable values. There are several values that can be configured there. Below lists out the configurable values and what they control. + +| Keys | Accepted Values | Definitions| +|-----------|:-----------:|:-----------| +| SSL_KEY | string | This is the path defined to the SSL private key file. Currently the application expects the key file to be stored in plain text | +| SSL_CERT | string | This is the path defined to the SSL public key file | +| USESSL | boolean | This enables or disables TLS. If this is set the SSL_KEY and SSL_CERT values must be defined. | +| PORTHTTPS | interger | This defines the HTTPS port. It is only used if the USESSL flag is set to true. If this is not set the applicatino will default to 8443. | +| PORTHTTP | interger | This defines the HTTP port. If this is not set the application will default to 8080. | +| DEBUG | boolean | This enables HTTP request debug logging to write to the console. This can be useful if you are troubleshooting what the application is seeing. | + +Below is a sample .ENV file + +``` text +SSL_KEY=./ssl/private/leaf.key +SSL_CERT=./ssl/private/chain.cer +USESSL=true +PORTHTTPS=8443 +PORTHTTP=8080 +DEBUG=true +``` + ## Usage Send a GET or POST request to the application, and it will respond with the request headers. diff --git a/index.js b/index.js index 6134434..036a1d9 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,6 @@ import dotenv from "dotenv"; import express from "express" import bodyParser from "body-parser"; -import morgan from "morgan"; import { dirname } from "path"; // this is to handle file path import { fileURLToPath } from "url"; // this is to handle file path import { url } from "inspector"; @@ -26,32 +25,27 @@ function logger(req, res, next) { next() } -app.use(logger) +if (process.env.DEBUG === "true") { + // Log incoming requests + app.use((req, res, next) => { + console.log(`Request received: ${req.method} ${req.originalUrl}\n Client IP: ${req.ip}\n Headers: ${JSON.stringify(req.headers, null, 2)}`); + next(); + }); + // Log response status after the response is sent + app.use((req, res, next) => { + const originalSend = res.send; + res.send = function (body) { + const protocol = req.protocol; // 'http' or 'https' + console.log(`Response sent for ${protocol.toUpperCase()} request: ${req.method} ${req.originalUrl} with status ${res.statusCode}`); + originalSend.call(this, body); + }; + next(); + }); +} // use body parser middleware we can use to mess with the body. app.use(bodyParser.urlencoded({ extended: true})); -// using Morgan middleware is a logging middleware -app.use(morgan('combined')) - -// Add logging middleware to differentiate HTTP and HTTPS requests -app.use((req, res, next) => { - const protocol = req.protocol; // 'http' or 'https' - console.log(`Received a ${protocol.toUpperCase()} request: ${req.method} ${req.originalUrl}`); - next(); -}); - -// Middleware to log response status after the response is sent -app.use((req, res, next) => { - const originalSend = res.send; - res.send = function (body) { - const protocol = req.protocol; // 'http' or 'https' - console.log(`Response sent for ${protocol.toUpperCase()} request: ${req.method} ${req.originalUrl} with status ${res.statusCode}`); - originalSend.call(this, body); - }; - next(); -}); - // handling GET /headers request app.get("/", (req, res) => { res.json({ @@ -59,8 +53,8 @@ app.get("/", (req, res) => { url: req.originalUrl, clientIP: req.ip, headers: req.headers - }) -}) + }); +}); // handling POST /headers request app.post("/", (req, res) => { @@ -69,8 +63,8 @@ app.post("/", (req, res) => { url: req.originalUrl, clientIP: req.ip, headers: req.headers - }) -}) + }); +}); // Create HTTP server const httpServer = http.createServer(app); From ada9dc58f30bb0700ddc1d931dc6f449103c32ac Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Fri, 11 Jul 2025 16:29:06 -0500 Subject: [PATCH 14/18] Correcting readme docs. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fdf2f0c..5bad92b 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ HeaderApp is a Node.js application that mirrors all request headers sent to it. 1. Clone the repository: ```sh - git clone https://github.com/Adal8819/headerapp.git + git clone https://github.com/DWBatmanPS/headerapp.git cd headerapp @@ -55,9 +55,9 @@ HeaderApp is a Node.js application that mirrors all request headers sent to it. 3. Run the Docker container: ```sh - docker run -p 3000:3000 headerapp + docker run -p 8080:8080 headerapp -4. The application will be running on [http://localhost:3000](http://localhost:3000) +4. The application will be running on [http://localhost:8080](http://localhost:8080) ### HTTP and HTTPS @@ -66,7 +66,7 @@ HeaderApp is a Node.js application that mirrors all request headers sent to it. 1. Clone the repository: ```sh - git clone https://github.com/yourusername/headerapp.git + git clone https://github.com/DWBatmanPS/headerapp.git cd headerapp 2. Install dependencies: From 9709a21f66c974ad31bb0d5c7057b1bfe2309a6e Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Fri, 11 Jul 2025 16:39:49 -0500 Subject: [PATCH 15/18] Comitting punctuation change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5bad92b..2b7522e 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ HeaderApp is a Node.js application that mirrors all request headers sent to it. ```sh docker run -v 'C:/path/to/your/ssl/files:/etc/ssl/certs' -p 8080:8080 -p 8443:8443 headerapp -6. The application will be running on [http://localhost:8080](http://localhost:8080) and [https://localhost:8443](https://localhost:8443). +6. The application will be running on [http://localhost:8080](http://localhost:8080) and [https://localhost:8443](https://localhost:8443) ## Environment configuration options From 63c30401bca4377ed473ddbe1db0c73bb1f3d4c1 Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Fri, 11 Jul 2025 16:49:20 -0500 Subject: [PATCH 16/18] correcting typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5bad92b..716fb48 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ HeaderApp is a Node.js application that mirrors all request headers sent to it. 1. Clone the repository: ```sh - git clone https://github.com/Adal8819/headerapp.git + git clone https://github.com/DWBatmanPS/headerapp.git cd headerapp 2. Install dependencies: From 340232d96fa634b4fa476d51c836738216f4fa20 Mon Sep 17 00:00:00 2001 From: Dan Wheeler Date: Fri, 11 Jul 2025 16:54:44 -0500 Subject: [PATCH 17/18] aligning main branch with upstream naming. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0a2777b..6648a1d 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ HeaderApp is a Node.js application that mirrors all request headers sent to it. 1. Clone the repository: ```sh - git clone https://github.com/DWBatmanPS/headerapp.git + git clone https://github.com/Adal8819/headerapp.git cd headerapp 2. Install dependencies: @@ -43,7 +43,7 @@ HeaderApp is a Node.js application that mirrors all request headers sent to it. 1. Clone the repository: ```sh - git clone https://github.com/DWBatmanPS/headerapp.git + git clone https://github.com/Adal8819/headerapp.git cd headerapp @@ -66,7 +66,7 @@ HeaderApp is a Node.js application that mirrors all request headers sent to it. 1. Clone the repository: ```sh - git clone https://github.com/DWBatmanPS/headerapp.git + git clone https://github.com/Adal8819/headerapp.git cd headerapp 2. Install dependencies: @@ -98,7 +98,7 @@ HeaderApp is a Node.js application that mirrors all request headers sent to it. 1. Clone the repository: ```sh - git clone https://github.com/yourusername/headerapp.git + git clone https://github.com/Adal8819/headerapp.git cd headerapp 2. Make sure that your SSL Certificates are in place. The application is designed to work with an unencrypted SSL key currently. From d76e40a3332caf155f931d70c86791c383471e1f Mon Sep 17 00:00:00 2001 From: Dan Wheeler <96199880+DWBatmanPS@users.noreply.github.com> Date: Fri, 26 Dec 2025 09:56:12 -0600 Subject: [PATCH 18/18] Set npm as the package ecosystem for Dependabot --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5f0889c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "npm" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly"