@checkfirst/nestjs-outlook
Version:
An opinionated NestJS module for Microsoft Outlook integration that provides easy access to Microsoft Graph API for emails, calendars, and more.
29 lines • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.delay = delay;
exports.retryWithBackoff = retryWithBackoff;
async function delay(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function retryWithBackoff(operation, options) {
var _a, _b, _c;
const maxRetries = (_a = options === null || options === void 0 ? void 0 : options.maxRetries) !== null && _a !== void 0 ? _a : 3;
const retryDelayMs = (_b = options === null || options === void 0 ? void 0 : options.retryDelayMs) !== null && _b !== void 0 ? _b : 1000;
const retryCount = (_c = options === null || options === void 0 ? void 0 : options.retryCount) !== null && _c !== void 0 ? _c : 0;
try {
return await operation();
}
catch (error) {
if (retryCount >= maxRetries) {
throw error;
}
const delayMs = retryDelayMs * Math.pow(2, retryCount);
await delay(delayMs);
return retryWithBackoff(operation, {
maxRetries,
retryDelayMs,
retryCount: retryCount + 1,
});
}
}
//# sourceMappingURL=retry.util.js.map