steam-family-bot-core
Version:
一个用于新版 Steam 家庭的库存监控 Bot 插件
34 lines • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Fetch = exports.createFetch = void 0;
const ofetch_1 = require("./ofetch");
const error_1 = require("./error");
const rofetch = (0, ofetch_1.createFetch)({
defaults: {
retryStatusCodes: [400, 408, 409, 425, 429, 502, 503, 504],
retry: 2,
retryDelay: 400,
},
});
const ofetch = new ofetch_1.Fetch(rofetch);
const createFetch = (logger) => {
return ofetch.extend({
onRequest: (context) => {
logger.debug(`[fetch -->] ${context.options.baseURL}${context.request}`);
},
onResponse: (context) => {
logger.debug(`[fetch <--] ${context.request} ${context.response.status}`);
},
onResponseError: (context) => {
if (context.response.status === 404) {
throw new error_1.NotFoundError();
}
throw context.error;
},
ignoreResponseError: false,
});
};
exports.createFetch = createFetch;
var ofetch_2 = require("./ofetch");
Object.defineProperty(exports, "Fetch", { enumerable: true, get: function () { return ofetch_2.Fetch; } });
//# sourceMappingURL=index.js.map