This is a simple URL shortener built using Express and ShortId. It allows users to generate short URLs for long URLs, and then use the short URLs to redirect to the original long URLs.
- Install Node.js and npm on your local machine if you haven't already.
- Clone this repository and navigate to the project directory.
- Run
npm install
to install the required dependencies. - Update the
port
andbaseUrl
variables in the code to match your desired configuration.
To generate a short URL for a long URL, make a GET request to /shorten
endpoint with the long URL as a query parameter, like this: http://localhost:3000/shorten?url=<LONG_URL>
. The server will respond with a short URL that you can use to redirect to the original long URL.
To redirect to the original long URL using the short URL, simply enter the short URL in your web browser or make a GET request to the short URL. The server will automatically redirect to the original long URL associated with the short URL.
If the short URL does not exist in the system, the server will respond with a 404 status code indicating that the URL was not found.
This project is licensed under the MIT License. Feel free to use, modify, and distribute it as per the terms of the license.