Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/trustmaster/metric-proxy
Proxy for web pages converting imperial units to metric units
https://github.com/trustmaster/metric-proxy
Last synced: 11 days ago
JSON representation
Proxy for web pages converting imperial units to metric units
- Host: GitHub
- URL: https://github.com/trustmaster/metric-proxy
- Owner: trustmaster
- License: mit
- Created: 2024-12-07T16:40:43.000Z (18 days ago)
- Default Branch: main
- Last Pushed: 2024-12-07T16:43:17.000Z (18 days ago)
- Last Synced: 2024-12-07T17:28:23.961Z (18 days ago)
- Language: TypeScript
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: License
Awesome Lists containing this project
README
# Metric Proxy
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.
## Getting Started
### Prerequisites
- Node.js
- npm
- Cloudflare Wrangler CLI### Installation
1. Clone the repository:
```sh
git clone https://github.com/yourusername/metric-proxy.git
cd metric-proxy
```2. Install dependencies:
```sh
npm install
```## How It Works
The main functionality is implemented in the [`convertHTMLToMetric`](src/index.ts) function in [src/index.ts](src/index.ts). This function:
1. Fetches HTML content from a given URL.
2. Uses regular expressions to find and convert imperial units (e.g., cups, ounces, pounds) to metric units (e.g., milliliters, grams).
3. 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.
### Development
To start the development server, run:
```sh
npm run dev
```### Deployment
To deploy the project to Cloudflare Workers, run:
```sh
npm run deploy
```### Testing
To run the tests, use:
```sh
npm test
```## License
This project is licensed under the MIT License.