Typescript to check on Vinland's MTA
Find a file
2025-08-20 14:16:36 +02:00
.claude Add in .claude dir. 2025-07-06 20:22:11 +02:00
index.html Added a button. Now there is a proxy but this is somewhat documented 2025-07-07 16:24:30 +02:00
proxy.js Added a button. Now there is a proxy but this is somewhat documented 2025-07-07 16:24:30 +02:00
README.md Initial commit. Claude wrote the code. 2025-07-06 20:21:11 +02:00
script.js Added a button. Now there is a proxy but this is somewhat documented 2025-07-07 16:24:30 +02:00
script.ts Added a button. Now there is a proxy but this is somewhat documented 2025-07-07 16:24:30 +02:00
style.css Add in styles.css 2025-08-20 14:16:36 +02:00

MTA Status Checker

A simple web application that checks the status of the MTA (Mail Transfer Agent) service by polling a health endpoint and displaying the results in a user-friendly interface.

Features

  • Click-to-check status button
  • Real-time status display with color coding:
    • Green: Service is healthy (status 200)
    • Red: Service has errors or is unavailable
  • Loading states during API calls
  • CORS-enabled proxy server to bypass browser restrictions

Files

  • index.html - Main web page with UI
  • script.ts - TypeScript source code
  • script.js - Compiled JavaScript (browser-ready)
  • proxy.js - Node.js proxy server to handle CORS

Setup and Usage

Prerequisites

  • Node.js (for running the proxy server)
  • TypeScript compiler (optional, for recompiling TypeScript)

Compiling TypeScript

If you make changes to script.ts, you'll need to recompile it to JavaScript:

# Install TypeScript globally (if not already installed)
npm install -g typescript

# Compile TypeScript to JavaScript
tsc script.ts --target es2017 --lib es2017,dom

Alternatively, if you don't have TypeScript installed, you can manually edit script.js directly.

Running the Application

  1. Start the proxy server:

    node proxy.js
    
  2. Open your browser and navigate to:

    http://localhost:8000
    
  3. Click the "Check Status" button to test the MTA service status.

How It Works

The application uses a proxy server to bypass CORS (Cross-Origin Resource Sharing) restrictions that browsers impose on cross-domain requests.

  • The web page makes requests to /api/status on the local server
  • The proxy server forwards these requests to https://mail.vinland.technology/healthz/ready
  • The proxy adds appropriate CORS headers to allow the browser to receive the response

API Response Format

The health endpoint returns JSON in this format:

{
  "type": "about:blank",
  "title": "OK",
  "status": 200,
  "detail": "OK"
}
  • status: 200 indicates the service is healthy
  • Any other status code indicates an error condition

Development

To modify the application:

  1. Edit script.ts for TypeScript changes
  2. Recompile with tsc script.ts --target es2017 --lib es2017,dom
  3. Restart the proxy server: node proxy.js
  4. Refresh your browser

Troubleshooting

  • CORS errors: Make sure you're accessing the page via http://localhost:8000 and not opening the HTML file directly
  • Network errors: Verify the proxy server is running and the target endpoint is accessible
  • TypeScript compilation errors: Check that your TypeScript syntax is correct and all required types are available