-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetQuoteFunc.js
More file actions
28 lines (28 loc) · 912 Bytes
/
getQuoteFunc.js
File metadata and controls
28 lines (28 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.dailyQuote = void 0;
exports.loadInitialQuote = loadInitialQuote;
const node_cron_1 = __importDefault(require("node-cron"));
const api_1 = require("./api");
exports.dailyQuote = null;
async function loadInitialQuote() {
try {
const response = await (0, api_1.getRandomQuote)();
exports.dailyQuote = response[0];
}
catch (err) {
console.error("Failed to load initial quote:", err);
}
}
node_cron_1.default.schedule('0 0 * * *', async () => {
try {
const response = await (0, api_1.getRandomQuote)();
exports.dailyQuote = response[0];
}
catch (err) {
console.error("Failed to update daily quote:", err);
}
});