This project is a URL shortener that allows users to shorten long URLs into shorter ones.
To get started with this project, follow these steps:
- Node.js installed on your machine
- MongoDB installed or access to a MongoDB instance
-
Clone the repository:
git clone https://github.com/codingXpert/URL-Shortener
-
Navigate to the project directory:
cd url-shortener -
Install dependencies:
npm install
-
Set up environment variables: Create a .env file in the root directory and define the following variables:
LOCAL_DATABASE=mongodb://localhost:27017/link_shortener PROD_DATABASE=mongodb+srv://<username>:<password>@<cluster>/<database> SALT_CONSTANT=10 JWT_SECRET=your_jwt_secret EXPIRES_IN=1d NODE_ENV=development
- To run the project in development mode:
npm run start:dev
- To run the project in production mode:
npm run start:prod
-
Short Url: AliasShorten long URLs into custom or randomly generated short URLs.
-
API Integration: Provide a RESTful API for users to programmatically interact with the URL shortening service.
-
JWT Authentication: Implemented JWT (JSON Web Token) authentication strategy for secure user login and session management.
-
MongoDB Atlas Integration: Employed MongoDB Atlas as the production database, ensuring scalability, reliability, and cloud-based data storage.
-
Security Middleware:
Helmet: Integrated Helmet to set various HTTP headers, enhancing security by protecting against common web vulnerabilities.
express-mongo-sanitize: Employed express-mongo-sanitize to sanitize user-supplied data against NoSQL Injection attacks.
xss-clean: Implemented xss-clean to sanitize user input from potential cross-site scripting (XSS) attacks, preventing script injections.
- Register User:
https://url-shortener-rfpt.onrender.com/api/user/register - User Login:
https://url-shortener-rfpt.onrender.com/api/user/login - Short Url:
https://url-shortener-rfpt.onrender.com/api/url/shorten - Access Original Url:
https://url-shortener-rfpt.onrender.com/api/url/9VelUQjTK
- Register User:
http://localhost:8000/api/user/register - User Login:
http://localhost:8000/api/user/login - Short Url:
http://localhost:8000/api/url/shorten - Access Original Url:
http://localhost:8000/api/url/9VelUQjTK
https://documenter.getpostman.com/view/20576167/2s9Ykrbzvk- Access all the available APIs using Swagger-UI
https://url-shortener-rfpt.onrender.com/api-docs/