MCPcopy
hub / github.com/fccview/jotty / writeJsonFile

Function writeJsonFile

app/_server/actions/file/index.ts:88–104  ·  view source on GitHub ↗
(
  data: any,
  filePath: string,
)

Source from the content-addressed store, hash-verified

86};
87
88export const writeJsonFile = async (
89 data: any,
90 filePath: string,
91): Promise<void> => {
92 const finalPath = path.join(process.cwd(), filePath);
93 const tmpPath = `${finalPath}.${randomUUID()}.tmp`;
94
95 try {
96 await fs.mkdir(path.dirname(finalPath), { recursive: true });
97 await fs.writeFile(tmpPath, JSON.stringify(data, null, 2), "utf-8");
98 await fs.rename(tmpPath, finalPath);
99 } catch (error) {
100 console.error("Error writing data:", error);
101 try { await fs.unlink(tmpPath); } catch {}
102 throw error;
103 }
104};
105
106export const readFile = async (filePath: string): Promise<string> => {
107 try {

Callers 15

generateMetadataFunction · 0.90
_deleteUserCoreFunction · 0.90
_updateUserCoreFunction · 0.90
createUserFunction · 0.90
updateUserSettingsFunction · 0.90
_writeFunction · 0.90
writeShareFileFunction · 0.90
_handleFailedLoginFunction · 0.90
registerFunction · 0.90
loginFunction · 0.90
verifyMfaLoginFunction · 0.90
adminDisableUserMfaFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected