This project implements a hit counter for a blog site using an Express server and a MongoDB database. Additionally, it relies on the JSON provided by the user-input-logger to log user information.
This hit counter and user input logger are integral parts of my blog site. They enhance the user experience by providing valuable insights into visitor interactions and engagement.
GitHub Repository : BLOG REPOSITORY
Live Project: BLOG SITE
Clone the repository:
git clone https://github.com/IntegerAlex/hitsregister
Install dependencies:
npm install
Set up environment variables:
Create a .env file in the root directory of the project and add the following variables:
MONGODB_USERNAME=<your-mongodb-username>
MONGO_DB_PASSWORD=<your-mongodb-password>Start the server:
npm start
Usage
Hit Counter Endpoint: The server listens for POST requests to /visit to register hits on the blog site. The client can send JSON data containing user information, and the server logs this information to the MongoDB database.
User Input Logger: This project includes a custom npm library called user-input-logger to log user information. This library logs information such as user agent, IP address, timestamp, etc., and stores it in the MongoDB database.
- Express: Fast, unopinionated, minimalist web framework for Node.js.
- MongoDB: General-purpose, document-based, distributed database built for modern application developers and for the cloud era.
- user-input-logger: Custom npm library for logging user input information. user-input-logger
Contributions are welcome! Please fork the repository, make changes, and submit a pull request.
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.