feat: add TLK string preview lookup for NWScript editor
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user