Metric Proxy is a Cloudflare Worker project designed to handle and process metrics efficiently. It fetches HTML content from a given URL, converts imperial units to metric units, and returns the modified HTML content.
- Node.js
- npm
- Cloudflare Wrangler CLI
-
Clone the repository:
git clone https://github.com/yourusername/metric-proxy.git cd metric-proxy -
Install dependencies:
npm install
The main functionality is implemented in the convertHTMLToMetric function in src/index.ts. This function:
- Fetches HTML content from a given URL.
- Uses regular expressions to find and convert imperial units (e.g., cups, ounces, pounds) to metric units (e.g., milliliters, grams).
- Returns the modified HTML content.
The worker listens for incoming requests, extracts the URL from the request, fetches the HTML content, processes it using convertHTMLToMetric, and returns the modified HTML content.
To start the development server, run:
npm run devTo deploy the project to Cloudflare Workers, run:
npm run deployTo run the tests, use:
npm testThis project is licensed under the MIT License.