treker-po-trenirovkam-i-pit.../server.js
Peppa 66524e37a3
Some checks failed
ci / checks (pull_request) Failing after 9s
deploy / deploy (pull_request) Failing after 15s
TPTIP-8: правки главной, план тренировок, рекорды, покупки, шаги и сон, фото прогресса, PWA и напоминания, копирование еды
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 16:53:11 +05:00

23 lines
1.1 KiB
JavaScript

// Мини-сервер для стенда: отдаёт файлы приложения, /healthz отвечает 200. Слушает $PORT.
const http = require('node:http');
const fs = require('node:fs');
const path = require('node:path');
const FILES = {
'/': ['index.html', 'text/html; charset=utf-8'],
'/index.html': ['index.html', 'text/html; charset=utf-8'],
'/manifest.webmanifest': ['manifest.webmanifest', 'application/manifest+json'],
'/sw.js': ['sw.js', 'text/javascript; charset=utf-8'],
'/icon.svg': ['icon.svg', 'image/svg+xml']
};
http.createServer((req, res) => {
const url = (req.url || '/').split('?')[0];
if (url === '/healthz') { res.writeHead(200, { 'content-type': 'text/plain' }); return res.end('ok'); }
const f = FILES[url];
if (!f) { res.writeHead(404); return res.end('not found'); }
fs.readFile(path.join(__dirname, f[0]), (err, buf) => {
if (err) { res.writeHead(500); return res.end('error'); }
res.writeHead(200, { 'content-type': f[1], 'cache-control': 'no-cache' });
res.end(buf);
});
}).listen(Number(process.env.PORT) || 3000, '0.0.0.0');