Skip to content

Instantly share code, notes, and snippets.

@deepak1556
Created January 27, 2026 12:10
Show Gist options
  • Select an option

  • Save deepak1556/2f0738f5f39616b8a33e1838de309a37 to your computer and use it in GitHub Desktop.

Select an option

Save deepak1556/2f0738f5f39616b8a33e1838de309a37 to your computer and use it in GitHub Desktop.
Test update server for macOS
const http = require('http');
const fs = require('fs');
const crypto = require('crypto');
const PORT = 8080;
const server = http.createServer((req, res) => {
const url = new URL(req.url, `http://localhost:${PORT}`);
console.log(`[${new Date().toISOString()}] ${req.method} ${url.pathname}`);
console.log(' Headers:', req.headers);
// Update check endpoint: GET /api/update/:platform/:quality/:commit
const updateMatch = url.pathname.match(/^\/api\/update\/([^/]+)\/([^/]+)\/([^/]+)$/);
if (updateMatch && req.method === 'GET') {
const [, platform, quality, currentCommit] = updateMatch;
console.log(` Platform: ${platform}, Quality: ${quality}, Current commit: ${currentCommit}`);
// Generate random version/commit on each request so there's always an update
const version = `${Math.floor(Math.random() * 100)}.${Math.floor(Math.random() * 100)}.${Math.floor(Math.random() * 100)}`;
const commit = crypto.randomBytes(20).toString('hex');
const response = {
url: `http://localhost:${PORT}/download/update.zip`,
name: version,
version: commit,
notes: commit,
productVersion: version,
timestamp: Date.now(),
sha256hash: crypto.randomBytes(32).toString('hex'),
supportsFastUpdate: false
};
console.log(` → 200 OK (update available: ${version})`);
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify(response, null, 2));
return;
}
// 404 for everything else
res.writeHead(404);
res.end('Not found');
});
server.listen(PORT, () => {
console.log(`\nVS Code Update Server running on http://localhost:${PORT}`);
console.log('Endpoints:');
console.log(` GET /api/update/:platform/:quality/:commit - Check for updates`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment