cloudflare
Version:
The official TypeScript library for the Cloudflare API
57 lines • 2.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Traces = exports.BaseTraces = void 0;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../core/resource.js");
const path_1 = require("../../internal/utils/path.js");
var BaseTraces = /* @__PURE__ */ (() => {
class BaseTraces extends resource_1.APIResource {
/**
* Traces a simulated HTTP request through Cloudflare's edge to analyze how rules,
* settings, and configurations would process the request. Useful for debugging
* firewall rules, page rules, and other request transformations without sending
* actual traffic. Supports custom headers, cookies, body content, and geolocation
* context.
*
* @example
* ```ts
* const trace = await client.requestTracers.traces.create({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* method: 'PUT',
* url: 'https://some.zone/some_path',
* body: { base64: 'c29tZV9yZXF1ZXN0X2JvZHk=' },
* context: {
* geoloc: { city: 'London' },
* skip_challenge: true,
* },
* cookies: {
* cookie_name_1: 'cookie_value_1',
* cookie_name_2: 'cookie_value_2',
* },
* headers: {
* header_name_1: 'header_value_1',
* header_name_2: 'header_value_2',
* },
* protocol: 'HTTP/1.1',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/request-tracer/trace`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
}
BaseTraces._key = Object.freeze([
'requestTracers',
'traces',
]);
return BaseTraces;
})();
exports.BaseTraces = BaseTraces;
class Traces extends BaseTraces {
}
exports.Traces = Traces;
//# sourceMappingURL=traces.js.map