chore: remove test UI and static file server for production

This commit is contained in:
Shekhar Vaidya 2026-04-10 20:50:05 +05:30
parent 74c06b0a8e
commit 722d211197

View file

@ -1,163 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MSDL Backend API Test</title>
<style>
body { font-family: system-ui, -apple-system, sans-serif; max-width: 800px; margin: 2rem auto; padding: 0 1rem; line-height: 1.5; color: #333; }
h1 { border-bottom: 2px solid #eee; padding-bottom: 0.5rem; }
.card { border: 1px solid #ddd; padding: 1.5rem; border-radius: 8px; margin-bottom: 1.5rem; background: #fafafa; }
.form-group { margin-bottom: 1rem; }
label { display: block; font-weight: 500; margin-bottom: 0.25rem; }
input, select { padding: 0.5rem; border: 1px solid #ccc; border-radius: 4px; width: 100%; max-width: 300px; }
.btn { background: #0066cc; color: white; border: none; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; font-weight: 500; }
.btn:hover { background: #0052a3; }
.btn:disabled { background: #ccc; cursor: not-allowed; }
pre { background: #1e1e1e; color: #d4d4d4; padding: 1rem; border-radius: 6px; overflow-x: auto; white-space: pre-wrap; font-size: 0.85rem; }
.error { color: #d32f2f; font-weight: 500; }
.success { color: #2e7d32; font-weight: 500; }
.hidden { display: none; }
</style>
</head>
<body>
<h1>MSDL API Test UI</h1>
<div class="card">
<h3>Step 1: Get Languages (SKU Info)</h3>
<div class="form-group">
<label for="productId">Product ID</label>
<!-- Default to Windows 11 (25H2) -->
<select id="productId">
<option value="3262">Windows 11 25H2 (3262)</option>
<option value="3321">Windows 11 25H2 New (3321)</option>
<option value="3113">Windows 11 24H2 (3113)</option>
<option value="2618">Windows 10 22H2 (2618)</option>
<option value="52">Windows 8.1 (52)</option>
</select>
</div>
<button id="btnGetLangs" class="btn">Fetch Languages</button>
<div id="langStatus" style="margin-top: 1rem;"></div>
</div>
<div id="step2Card" class="card hidden">
<h3>Step 2: Get Download Links (Proxy)</h3>
<div class="form-group">
<label for="skuId">Select Language (SKU)</label>
<select id="skuId"></select>
</div>
<button id="btnGetLinks" class="btn">Fetch Download Links</button>
<div id="linkStatus" style="margin-top: 1rem;"></div>
</div>
<div class="card">
<h3>API Response</h3>
<pre id="jsonOutput">Ready.</pre>
</div>
<script>
const baseUrl = window.location.origin; // e.g. http://localhost:3001
const productIdEl = document.getElementById('productId');
const skuIdEl = document.getElementById('skuId');
const btnGetLangs = document.getElementById('btnGetLangs');
const btnGetLinks = document.getElementById('btnGetLinks');
const langStatus = document.getElementById('langStatus');
const linkStatus = document.getElementById('linkStatus');
const step2Card = document.getElementById('step2Card');
const jsonOutput = document.getElementById('jsonOutput');
function output(obj, isError = false) {
jsonOutput.textContent = JSON.stringify(obj, null, 2);
jsonOutput.style.color = isError ? '#ff8a80' : '#81c784';
}
let currentProductId = null;
btnGetLangs.addEventListener('click', async () => {
const pid = productIdEl.value;
btnGetLangs.disabled = true;
langStatus.innerHTML = '<i>Fetching languages... this takes a few seconds to warm up the Microsoft session.</i>';
step2Card.classList.add('hidden');
jsonOutput.style.color = '#d4d4d4';
jsonOutput.textContent = 'Loading...';
try {
const res = await fetch(`${baseUrl}/skuinfo?product_id=${pid}`);
const data = await res.json();
if (!res.ok || data.error) {
throw new Error(data.error || 'Server error');
}
output(data);
langStatus.innerHTML = `<span class="success">Found ${data.Skus.length} languages!</span>`;
// Populate step 2
skuIdEl.innerHTML = '';
data.Skus.forEach(sku => {
const opt = document.createElement('option');
opt.value = sku.Id;
opt.textContent = sku.LocalizedLanguage;
// select english by default if exists
if (sku.LocalizedLanguage.toLowerCase().includes('english')) {
opt.selected = true;
}
skuIdEl.appendChild(opt);
});
currentProductId = pid;
step2Card.classList.remove('hidden');
} catch (err) {
langStatus.innerHTML = `<span class="error">${err.message}</span>`;
output({ error: err.message }, true);
} finally {
btnGetLangs.disabled = false;
}
});
btnGetLinks.addEventListener('click', async () => {
const sid = skuIdEl.value;
if (!sid || !currentProductId) return;
btnGetLinks.disabled = true;
linkStatus.innerHTML = '<i>Fetching download links...</i>';
jsonOutput.style.color = '#d4d4d4';
jsonOutput.textContent = 'Loading...';
try {
const res = await fetch(`${baseUrl}/proxy?product_id=${currentProductId}&sku_id=${sid}`);
const data = await res.json();
if (!res.ok || data.error) {
throw new Error(data.error || 'Server error');
}
output(data);
if (data.ProductDownloadOptions && data.ProductDownloadOptions.length > 0) {
let linksHtml = '<div style="margin-top:10px;">';
data.ProductDownloadOptions.forEach(opt => {
linksHtml += `<div style="margin-bottom:10px;">
<strong>${opt.Architecture}</strong>:
<br><a href="${opt.Uri}" target="_blank" style="word-break: break-all; color: #0066cc;">${opt.Uri}</a>
</div>`;
});
linksHtml += '</div>';
linkStatus.innerHTML = `<span class="success">Success! Links generated:</span>${linksHtml}`;
} else {
linkStatus.innerHTML = `<span class="error">No links found in response.</span>`;
}
} catch (err) {
linkStatus.innerHTML = `<span class="error">${err.message}</span>`;
output({ error: err.message }, true);
} finally {
btnGetLinks.disabled = false;
}
});
</script>
</body>
</html>