feat: add global workspace search with regex and file filtering
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
readFile,
|
||||
writeFile,
|
||||
deleteFile,
|
||||
searchFiles,
|
||||
} from "../services/editor.service.js";
|
||||
import { lookupResref, getResrefCount } from "../nwscript/resref-index.js";
|
||||
import { lookupTlk, getTlkCount } from "../nwscript/tlk-index.js";
|
||||
@@ -51,6 +52,18 @@ router.delete("/file/:repo/*path", async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
router.post("/search", async (req, res) => {
|
||||
const { repo, query, regex, caseSensitive, includePattern, excludePattern, maxResults } = req.body;
|
||||
if (!repo || !query) return res.status(400).json({ error: "repo and query required" });
|
||||
try {
|
||||
const results = await searchFiles(repo, query, { regex, caseSensitive, includePattern, excludePattern, maxResults });
|
||||
res.json(results);
|
||||
} catch (err: unknown) {
|
||||
const message = err instanceof Error ? err.message : "Unknown error";
|
||||
res.status(500).json({ error: message });
|
||||
}
|
||||
});
|
||||
|
||||
router.get("/resref/:resref", (req, res) => {
|
||||
const entry = lookupResref(req.params.resref);
|
||||
if (entry) {
|
||||
|
||||
Reference in New Issue
Block a user