add re-execute API

error hundling
This commit is contained in:
kosukesuenaga 2025-12-05 16:01:59 +09:00
parent 395fba645d
commit c004f6c34f
6 changed files with 99 additions and 93 deletions

View file

@ -24,30 +24,32 @@ export const fileController = {
minutesContent += minutes;
return minutesContent;
},
createZip: async (body: any, outputPath: string, fileName: string) => {
console.log(outputPath);
await new Promise((resolve, reject) => {
const output = fs.createWriteStream(outputPath);
const archive = archiver('zip', {
zlib: { level: 9 }
});
createZip: async (body: any, outputPath: string, fileName: string): Promise<boolean> => {
try {
await new Promise((resolve, reject) => {
const output = fs.createWriteStream(outputPath);
const archive = archiver('zip', {
zlib: { level: 9 }
});
output.on('close', () => {
console.log(archive.pointer() + ' total bytes');
console.log('archiver has been finalized and the output file descriptor has closed.');
resolve(true);
});
output.on('close', () => {
// console.log(archive.pointer() + ' total bytes');
// console.log('archiver has been finalized and the output file descriptor has closed.');
resolve(true);
});
archive.on('error', (err) => {
reject(err);
});
archive.on('error', (err) => {
reject(err);
});
archive.pipe(output);
archive.append(JSON.stringify(body), { name: fileName + '.json' });
archive.finalize();
})
console.log("ZIP created");
return;
archive.pipe(output);
archive.append(JSON.stringify(body), { name: fileName + '.json' });
archive.finalize();
})
return true;
} catch(error) {
return false;
}
},
};