forked from ryanmwangi/CalMerger
generate a unique identifier for each set of calendars
This commit is contained in:
parent
5ac43ae974
commit
6c9af1f4e4
11
server.js
11
server.js
|
@ -7,7 +7,13 @@ import axios from 'axios';
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
let mergedCalendarUrl = '';
|
const CALENDARS_FILE = 'calendars.json';
|
||||||
|
const MERGED_CALENDARS_DIR = 'merged_calendars';
|
||||||
|
|
||||||
|
// Ensure the merged calendars directory exists
|
||||||
|
if (!fs.existsSync(MERGED_CALENDARS_DIR)) {
|
||||||
|
fs.mkdirSync(MERGED_CALENDARS_DIR);
|
||||||
|
}
|
||||||
|
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
res.sendFile('index.html', { root: '.' });
|
res.sendFile('index.html', { root: '.' });
|
||||||
|
@ -21,6 +27,9 @@ app.post('/merge', async (req, res) => {
|
||||||
if (!calendars || !Array.isArray(calendars)) {
|
if (!calendars || !Array.isArray(calendars)) {
|
||||||
return res.status(400).json({ error: 'Invalid input' });
|
return res.status(400).json({ error: 'Invalid input' });
|
||||||
}
|
}
|
||||||
|
// Generate a unique identifier for this set of calendars
|
||||||
|
const calendarId = crypto.randomBytes(16).toString('hex');
|
||||||
|
|
||||||
// Fetch calendar data from URLs
|
// Fetch calendar data from URLs
|
||||||
const promises = calendars.map((calendar) => {
|
const promises = calendars.map((calendar) => {
|
||||||
return axios.get(calendar.url)
|
return axios.get(calendar.url)
|
||||||
|
|
Loading…
Reference in New Issue