A simple Node.js URL shortener using ExpressJS and MongoDB.
-
Clone the repository:
git clone https://github.com/mohamadayash22/node-url-shortener.git
-
Install the project dependencies
cd node-url-shortener npm install
-
Configure the environment variables
PORT=3000 MONGODB_URI=your-mongodb-uri BASE_URL=your-api-base-url
-
To run the app in dev mode
npm run dev
-
To run the app in production mode
npm start
To use the URL shortener API, make HTTP requests to the following endpoints:
- POST /api/shorten: Shorten a long URL.
- GET /{urlId}: Redirect to the original URL.
For detailed information about the available API endpoints, please refer to the BASE_URL/api-docs
, where BASE_URL
is your API's base URL as configured in your environment file.
You can access the Swagger documentation by replacing BASE_URL
with the actual base URL of your API.