python -> node.js

This commit is contained in:
kosukesuenaga 2025-12-05 14:12:11 +09:00
parent 092f2ec0f3
commit 395fba645d
62 changed files with 726 additions and 1702 deletions

View file

@ -0,0 +1,53 @@
import { create } from "domain";
import { dateController } from "./date";
import path, { join } from "path";
import archiver from "archiver";
import { googleDriveController } from "./googleDrive";
import fs from "fs";
export const fileController = {
createMinutesFileName: (title: string, hostName: string, jstStartsAt: Date): string => {
const dateStr = dateController.getFormattedDate(jstStartsAt, "yyyy年MM月dd日");
const fileName = `${dateStr} ${title} ${hostName}`;
return fileName;
},
extractCompanyNameFromTitle: (title: string) => {
const normalizedTitle = title.replace("【", "").replace("】", "");
const companyName = normalizedTitle.split("様")[0];
return companyName
},
createMinutesContent: (videoUrl: string, hostName: string, minutes: string): string => {
let minutesContent = `会議履歴URL${videoUrl}\n`;
minutesContent += `担当者:${hostName}\n\n`;
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 }
});
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.pipe(output);
archive.append(JSON.stringify(body), { name: fileName + '.json' });
archive.finalize();
})
console.log("ZIP created");
return;
},
};