initial commit

This commit is contained in:
chungyeong
2026-02-19 17:28:58 +09:00
commit 02970df6af
34 changed files with 5673 additions and 0 deletions

34
src/dashboardAssets.js Normal file
View File

@@ -0,0 +1,34 @@
"use strict";
const fs = require("node:fs");
const path = require("node:path");
const { createHttpError } = require("./dashboardUtils");
const ASSET_MAP = {
"/": { file: "index.html", contentType: "text/html; charset=utf-8" },
"/dashboard.css": { file: "dashboard.css", contentType: "text/css; charset=utf-8" },
"/dashboard.js": {
file: "dashboard.js",
contentType: "application/javascript; charset=utf-8",
},
};
function loadDashboardAsset(assetsDir, requestPath) {
const asset = ASSET_MAP[requestPath];
if (!asset) return null;
const filePath = path.join(assetsDir, asset.file);
if (!fs.existsSync(filePath)) {
throw createHttpError(500, `대시보드 파일이 없습니다: ${asset.file}`);
}
return {
content: fs.readFileSync(filePath),
contentType: asset.contentType,
};
}
module.exports = {
ASSET_MAP,
loadDashboardAsset,
};