This is a Node.js application that retrieves the public IP address of the client.
Before running this application, make sure you have the following prerequisites installed on your system:
- Node.js: Download and Install Node.js
-
Clone the repository:
git clone https://github.com/cemonal/nodejs-ip-info.git
-
Navigate to the project directory:
cd nodejs-ip-info
-
Install the dependencies:
npm install
-
Start the application:
npm start
The server will be running on port 3000 by default. You can configure the port and other settings in the config.js
file.
To use the API, simply make GET requests to the appropriate endpoints. The main endpoint for retrieving the client's public IP address is:
GET /
You can replace the base URL with your server's address if needed.
You can configure the application settings in the config.js
file. Here are the available configuration options:
rateLimit
: Configure rate limiting settings, such as the time window and maximum number of requests allowed.port
: Configure the port on which the server will listen.
This application exposes the following endpoint:
/
: This endpoint retrieves the public IP address of the client.
To prevent abuse of the API, rate limiting is applied. The default rate limiting settings are defined in the configuration file, but you can customize them to suit your needs.
Global error handling is implemented to ensure that errors are logged and provide feedback to clients in case of unexpected errors. The error handling middleware logs errors and responds with an error message.
Contributions to this project are welcome! If you'd like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and test thoroughly.
- Commit your changes with clear and concise commit messages.
- Push your changes to your forked repository.
- Create a pull request to the original repository, explaining your changes and the problem they solve.
Thank you for contributing!