Files
MagicMirror/defaultmodules/calendar/debug.js
T

41 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-08-12 22:52:43 +02:00
/*
* CalendarFetcher Tester
* use this script with `node debug.js` to test the fetcher without the need
2022-01-26 23:47:51 +01:00
* of starting the MagicMirror² core. Adjust the values below to your desire.
2016-04-15 12:18:59 +02:00
*/
// Load internal alias resolver
require("../../js/alias-resolver");
const Log = require("logger");
2021-05-07 12:28:55 +02:00
2023-04-04 20:44:32 +02:00
const CalendarFetcher = require("./calendarfetcher");
const url = "https://calendar.google.com/calendar/ical/pkm1t2uedjbp0uvq1o7oj1jouo%40group.calendar.google.com/private-08ba559f89eec70dd74bbd887d0a3598/basic.ics"; // Standard test URL
//const url = "https://www.googleapis.com/calendar/v3/calendars/primary/events/"; // URL for Bearer auth (must be configured in Google OAuth2 first)
const fetchInterval = 60 * 60 * 1000;
const maximumEntries = 10;
const maximumNumberOfDays = 365;
const user = "magicmirror";
const pass = "MyStrongPass";
const auth = {
user: user,
pass: pass
};
2016-04-15 12:18:59 +02:00
Log.log("Create fetcher ...");
2016-04-15 12:18:59 +02:00
const fetcher = new CalendarFetcher(url, fetchInterval, [], maximumEntries, maximumNumberOfDays, auth);
2016-04-15 12:18:59 +02:00
2020-05-11 22:22:32 +02:00
fetcher.onReceive(function (fetcher) {
Log.log(fetcher.events);
2021-05-07 12:28:55 +02:00
process.exit(0);
2016-04-15 12:18:59 +02:00
});
2020-05-11 22:22:32 +02:00
fetcher.onError(function (fetcher, error) {
Log.log("Fetcher error:", error);
2021-05-07 12:28:55 +02:00
process.exit(1);
2016-04-15 12:18:59 +02:00
});
fetcher.startFetch();
Log.log("Create fetcher done! ");