feat: add TLK string preview lookup for NWScript editor

This commit is contained in:
plenarius
2026-04-20 19:11:32 -04:00
parent 1b8293627d
commit 99d0c4f1e9
2 changed files with 48 additions and 0 deletions
+16
View File
@@ -6,6 +6,7 @@ import {
deleteFile,
} from "../services/editor.service.js";
import { lookupResref, getResrefCount } from "../nwscript/resref-index.js";
import { lookupTlk, getTlkCount } from "../nwscript/tlk-index.js";
const router = Router();
@@ -62,4 +63,19 @@ router.get("/resref-count", (_req, res) => {
res.json({ count: getResrefCount() });
});
router.get("/tlk/:id", (req, res) => {
const id = parseInt(req.params.id, 10);
if (isNaN(id)) return res.status(400).json({ error: "invalid id" });
const text = lookupTlk(id);
if (text !== undefined) {
res.json({ id, text });
} else {
res.status(404).json({ error: "TLK entry not found" });
}
});
router.get("/tlk-count", (_req, res) => {
res.json({ count: getTlkCount() });
});
export default router;