Rocky_Mountain_Vending/.pnpm-store/v10/files/9a/6b65023ad8dad64030f2a59ad48f188885f125df8d3e09553b52d09c204332da64e46d2625a91879a13431d9120703ef7d39b45265794ece9d65276228c018
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

46 lines
1.9 KiB
Text

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchResource = fetchResource;
const node_http_1 = __importDefault(require("node:http"));
const node_https_1 = __importDefault(require("node:https"));
const get_proxy_agent_1 = require("./get-proxy-agent");
/**
* Makes a simple GET request and returns the entire response as a Buffer.
* - Throws if the response status is not 200.
* - Applies a 3000 ms timeout when `isDev` is `true`.
*/
function fetchResource(url, isDev, errorMessage) {
return new Promise((resolve, reject) => {
const { protocol } = new URL(url);
const client = protocol === 'https:' ? node_https_1.default : node_http_1.default;
const timeout = isDev ? 3000 : undefined;
const req = client.request(url, {
agent: (0, get_proxy_agent_1.getProxyAgent)(),
headers: {
// The file format is based off of the user agent, make sure woff2 files are fetched
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) ' +
'AppleWebKit/537.36 (KHTML, like Gecko) ' +
'Chrome/104.0.0.0 Safari/537.36',
},
}, (res) => {
if (res.statusCode !== 200) {
reject(new Error(errorMessage ||
`Request failed: ${url} (status: ${res.statusCode})`));
return;
}
const chunks = [];
res.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
res.on('end', () => resolve(Buffer.concat(chunks)));
});
if (timeout) {
req.setTimeout(timeout, () => {
req.destroy(new Error(`Request timed out after ${timeout}ms`));
});
}
req.on('error', (err) => reject(err));
req.end();
});
}