ambiere / headerparser

Simple API built with Node.js and Express that extracts and parses information from HTTP request headers.

Home Page:https://headerparser.fly.dev/v0/api/headerparser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

js-standard-style   Test   Deployment  

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:

git clone https://github.com/zhid0399123/headerparser.git
cd headerparser
pnpm install

2.0 Start the Server:

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:

curl http://0.0.0.0:3000/v0/api/headerparser/whoami

Response:

{
  "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.

  2. Usage Examples: Here's an example using cURL to convert a timestamp to Unix time:

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 to get started.

License

This project is licensed under the MIT License. Refer to the LICENSE file for more details.

About

Simple API built with Node.js and Express that extracts and parses information from HTTP request headers.

https://headerparser.fly.dev/v0/api/headerparser

License:MIT License


Languages

Language:JavaScript 65.9%Language:CSS 16.0%Language:HTML 13.6%Language:Dockerfile 4.5%