check if .ics file exists

This commit is contained in:
Ryan Mwangi 2024-10-24 15:20:52 +03:00
parent 50ad583698
commit 96e25f7169
1 changed files with 9 additions and 0 deletions

View File

@ -112,6 +112,15 @@ app.get('/calendar/:name', async (req, res) => {
const icsFilePath = path.join(MERGED_CALENDARS_DIR, `${calendarName}.ics`);
const jsonFilePath = path.join(MERGED_CALENDARS_DIR, `${calendarName}.json`);
try {
// Check if the .ics file exists
if (fs.existsSync(icsFilePath)) {
const stats = fs.statSync(icsFilePath);
const lastModified = new Date(stats.mtime);
const now = new Date();
}
}
});
// Serve the merged calendar file