fix: add static server for run, keep app static

This commit is contained in:
askar_gazizov 2026-11-19 04:43:26 +00:00
parent 900e01ccb0
commit abdbf555aa
5 changed files with 88 additions and 0 deletions

36
.vibe42-run.log Normal file
View File

@ -0,0 +1,36 @@
--- run Thu Nov 19 04:42:35 AM UTC 2026 :: node app.js
/srv/opencode/workspaces/users/askar_gazizov/kazakhtelecom-ai-agent/app.js:1
(window.hse = window.hse || {});
^
ReferenceError: window is not defined
at Object.<anonymous> (/srv/opencode/workspaces/users/askar_gazizov/kazakhtelecom-ai-agent/app.js:1:1)
at Module._compile (node:internal/modules/cjs/loader:1521:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1623:10)
at Module.load (node:internal/modules/cjs/loader:1266:32)
at Module._load (node:internal/modules/cjs/loader:1091:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:164:12)
at node:internal/main/run_main_module:28:49
Node.js v20.20.2
--- run Thu Nov 19 04:42:50 AM UTC 2026 :: node app.js
up to date in 436ms
/srv/opencode/workspaces/users/askar_gazizov/kazakhtelecom-ai-agent/app.js:1
(window.hse = window.hse || {});
^
ReferenceError: window is not defined
at Object.<anonymous> (/srv/opencode/workspaces/users/askar_gazizov/kazakhtelecom-ai-agent/app.js:1:1)
at Module._compile (node:internal/modules/cjs/loader:1521:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1623:10)
at Module.load (node:internal/modules/cjs/loader:1266:32)
at Module._load (node:internal/modules/cjs/loader:1091:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:164:12)
at node:internal/main/run_main_module:28:49
Node.js v20.20.2
--- run Thu Nov 19 04:43:14 AM UTC 2026 :: npm start --silent
up to date in 404ms
Сервер на порту 3000

1
.vibe42-run.pid Normal file
View File

@ -0,0 +1 @@
292

12
package-lock.json generated Normal file
View File

@ -0,0 +1,12 @@
{
"name": "kazakhtelecom-ai-agent",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "kazakhtelecom-ai-agent",
"version": "1.0.0"
}
}
}

10
package.json Normal file
View File

@ -0,0 +1,10 @@
{
"name": "kazakhtelecom-ai-agent",
"private": true,
"version": "1.0.0",
"type": "commonjs",
"scripts": {
"start": "node server.js"
},
"dependencies": {}
}

29
server.js Normal file
View File

@ -0,0 +1,29 @@
const http = require("http");
const fs = require("fs");
const path = require("path");
const PORT = process.env.PORT || 3000;
const MIME = {
".html": "text/html; charset=utf-8",
".css": "text/css; charset=utf-8",
".js": "application/javascript; charset=utf-8",
".json": "application/json; charset=utf-8",
".png": "image/png",
".svg": "image/svg+xml",
".woff2": "font/woff2",
".ico": "image/x-icon"
};
http.createServer((req, res) => {
let file = decodeURIComponent(req.url.split("?")[0]);
if (file === "/") file = "/index.html";
const full = path.join(__dirname, file);
if (!full.startsWith(__dirname)) { res.writeHead(403); return res.end("Forbidden"); }
if (fs.existsSync(full) && fs.statSync(full).isFile()) {
res.writeHead(200, { "Content-Type": MIME[path.extname(full).toLowerCase()] || "application/octet-stream" });
return res.end(fs.readFileSync(full));
}
res.writeHead(404);
res.end("Not found");
}).listen(PORT, () => console.log("Сервер на порту " + PORT));