A simple Node.js application that shortens long URLs and keeps track of usage analytics, such as click count, IP address, and user agent information for each URL.
- URL Shortening: Converts long URLs into short, easy-to-share links.
- Analytics Tracking: Records data for each click, including:
- Date and time of click
- User's IP address
- User agent information
- Dashboard: Displays a table of shortened URLs, click counts, creation dates, and optional expiration dates.
-
Clone the repository:
git clone https://github.com/dnesbala/node-url-shortener.git cd node-url-shortener
-
Install dependencies:
npm install
- Environment Setup: Create a .env file in the root directory and set the required environment variables:
PORT=8000
MONGO_DB_URL=your_mongodb_connection_string
- Run the application:
npm start
- Access the app: Go to http://localhost:8000 in your browser.
- Shorten a URL: Use the form on the homepage to shorten a URL.
- View Analytics: See click analytics for each URL in a table format on the dashboard.
- User Authentication: Secure access for analytics and URL management.
- Custom Short URL: Allows users to specify custom URLs for their shortened links.
- Expiration Logic: Optionally set expiration dates for shortened URLs.
- Enhanced Analytics: Include geographic data and device types.
- API Access: Provide API endpoints for creating and managing shortened URLs.
- Node.js & Express: Backend server and routing.
- MongoDB: Database for storing URL and analytics data.
- EJS: Template engine for rendering dynamic HTML pages.
- CSS: Styling for the frontend.