feat: drop /docs URL prefix (variant B, shorter URLs) + bump 0.0.2

This commit is contained in:
“Naeel”
2026-09-02 15:17:14 +03:00
parent 69460e9652
commit 658e6e9c7f
3 changed files with 9 additions and 25 deletions
+3 -19
View File
@@ -5,7 +5,7 @@ const path = require('path');
const { S3Client, GetObjectCommand, HeadBucketCommand } = require('@aws-sdk/client-s3');
const PORT = process.env.PORT || 3000;
const VERSION = process.env.APP_VERSION || '0.0.1';
const VERSION = process.env.APP_VERSION || '0.0.2';
const SERVICE = 'tf-docs';
const S3_BUCKET = process.env.S3_BUCKET || '';
const DOCS_S3_PREFIX = (process.env.DOCS_S3_PREFIX || 'docs').replace(/^\/+|\/+$/g, '');
@@ -22,7 +22,7 @@ const s3 = new S3Client({
});
function getDocsCandidates(urlPath) {
const relativePath = decodeURIComponent(urlPath.replace(/^\/docs\/?/, ''));
const relativePath = decodeURIComponent(urlPath.replace(/^\/+/, ''));
const normalized = path.posix.normalize(`/${relativePath}`).replace(/^\/+|\/+$/g, '');
if (!normalized || normalized === '.' || normalized.startsWith('../') || normalized.includes('/../')) {
return null;
@@ -106,23 +106,7 @@ const server = http.createServer((req, res) => {
health(req, res);
return;
}
if (req.url.startsWith('/docs/')) {
docsHandler(req, res);
return;
}
res.statusCode = 200;
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.end(`<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<title>${SERVICE}</title>
</head>
<body>
<h1>${SERVICE}</h1>
<p>version: ${VERSION}</p>
</body>
</html>`);
docsHandler(req, res);
});
if (require.main === module) {