MCPcopy Create free account
hub / github.com/lowdefy/lowdefy / createReadConfigFile

Function createReadConfigFile

packages/api/src/context/createReadConfigFile.js:23–38  ·  view source on GitHub ↗
({ buildDirectory, fileCache })

Source from the content-addressed store, hash-verified

21const validPathPattern = /^[A-Za-z0-9\-_/.:]+$/;
22
23function createReadConfigFile({ buildDirectory, fileCache }) {
24 async function readConfigFile(filePath) {
25 if (!validPathPattern.test(filePath) || filePath.includes('..')) {
26 return null;
27 }
28 const fileContent = await readFile(path.resolve(buildDirectory, filePath));
29 if (getFileExtension(filePath) === 'json') {
30 return serializer.deserializeFromString(fileContent);
31 }
32 return fileContent;
33 }
34 return cachedPromises({
35 cache: fileCache,
36 getter: readConfigFile,
37 });
38}
39
40export default createReadConfigFile;

Callers 2

createApiContextFunction · 0.70

Calls 1

cachedPromisesFunction · 0.90

Tested by

no test coverage detected