https://github.com/ambiere/headerparser
Simple API built with Node.js and Express that extracts and parses information from HTTP request headers.
https://github.com/ambiere/headerparser
express freecodecamp-project header-parser microservice nodejs
Last synced: 7 months ago
JSON representation
Simple API built with Node.js and Express that extracts and parses information from HTTP request headers.
- Host: GitHub
- URL: https://github.com/ambiere/headerparser
- Owner: ambiere
- License: mit
- Created: 2023-12-01T09:10:46.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-04T11:07:11.000Z (about 2 years ago)
- Last Synced: 2025-04-01T19:28:06.511Z (11 months ago)
- Topics: express, freecodecamp-project, header-parser, microservice, nodejs
- Language: JavaScript
- Homepage: https://headerparser.fly.dev/v0/api/headerparser
- Size: 106 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
## headerparser
The Request Header Parser is a simple API built with Node.js and Express that extracts and parses information from HTTP request headers. It provides endpoints to retrieve details such as IP address, preferred languages, software platform, and other relevant metadata from incoming HTTP requests.
[](https://standardjs.com/)
[](https://github.com/zhid0399123/headerparser/actions/workflows/CI.yml)
[](https://github.com/zhid0399123/headerparser/actions/workflows/fly.yml)
## Purpose
The Request Header Parser is designed to assist developers in retrieving and parsing essential client information from request headers, aiding in various use cases such as user analytics, language preferences, and client compatibility detection.
## Features
1. **IP Address**: Obtain the client's IP address from the request headers.
2. **Preferred Languages**: Retrieve the preferred languages set in the client's browser.
3. **Software Platform**: Identify the client's operating system and browser information.
4. **User-Agent Parsing**: Extract user-agent details for detailed device and browser information.
## Usage locally
### 1.0 Installation:
```bash
git clone https://github.com/zhid0399123/headerparser.git
cd headerparser
pnpm install
```
### 2.0 Start the Server:
```bash
npm start
```
The server runs on http://0.0.0.0:3000/v0/api/headerparser/whoami by default. You can modify the port in your `.env` file
### 3.0 Endpoint:
Send a GET request to `http://0.0.0.0:3000/v0/api/headerparser/whoami` endpoint to retrieve client's IP address, preferred languages, and user-agent information.
Example:
```bash
curl http://0.0.0.0:3000/v0/api/headerparser/whoami
```
Response:
```json
{
"id": "e7757827-c456-4354-9b98-b9ebfee29705",
"ipAddress": "159.20.14.100",
"languages": "en-US,en;q=0.5",
"userAgent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0"
}
```
## Deployment
The **headerparser** Microservice is deployed and accessible via fly.io, allowing users to interact with the API endpoints. Follow these steps to access the deployed API:
1. **Base URL**: The deployed API can be accessed at [https://headerparser.fly.dev/v0/api/headerparser/whoami](https://headerparser.fly.dev/v0/api/headerparser/whoami).
2. **Usage Examples**: Here's an example using cURL to convert a timestamp to Unix time:
```bash
curl -X GET https://headerparser.fly.dev/v0/api/headerparser/whoami
```
## API Endpoints
`GET /v0/api/headerparser/whoami` Retrieve request header information.
## Contributing
Contributions are welcome! Feel free to open issues or submit pull requests. Please refer to the [Contributing Guidelines](CONTRIBUTING.md) to get started.
## License
This project is licensed under the MIT License. Refer to the [LICENSE](LICENSE) file for more details.