Typescript to check on Vinland's MTA
| .claude | ||
| index.html | ||
| proxy.js | ||
| README.md | ||
| script.js | ||
| script.ts | ||
| style.css | ||
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 UIscript.ts- TypeScript source codescript.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
-
Start the proxy server:
node proxy.js -
Open your browser and navigate to:
http://localhost:8000 -
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/statuson 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: 200indicates the service is healthy- Any other status code indicates an error condition
Development
To modify the application:
- Edit
script.tsfor TypeScript changes - Recompile with
tsc script.ts --target es2017 --lib es2017,dom - Restart the proxy server:
node proxy.js - Refresh your browser
Troubleshooting
- CORS errors: Make sure you're accessing the page via
http://localhost:8000and 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