Phase 1 reliability/stabilisation: auth logging, logout client, loader+xml hardening
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
const xmlCache = new Map();
|
||||
|
||||
/**
|
||||
* Reads /data/formsxml/{appealtypes}.xml and normalises it.
|
||||
* Returns { xmlStr } or throws on missing file.
|
||||
@@ -9,6 +11,10 @@ import path from "path";
|
||||
export function readFormXml(appealtypes) {
|
||||
if (!appealtypes) throw new Error("readFormXml: appealtypes is required");
|
||||
|
||||
if (xmlCache.has(appealtypes)) {
|
||||
return xmlCache.get(appealtypes);
|
||||
}
|
||||
|
||||
const configDirectory = path.resolve(process.cwd(), "data/formsxml");
|
||||
const filePath = path.join(configDirectory, `${appealtypes}.xml`);
|
||||
|
||||
@@ -20,5 +26,8 @@ export function readFormXml(appealtypes) {
|
||||
xmlStr = xmlStr.replace(/> <"/g, "><");
|
||||
xmlStr = xmlStr.toString();
|
||||
|
||||
return { xmlStr, filePath };
|
||||
const result = { xmlStr, filePath };
|
||||
xmlCache.set(appealtypes, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user