A URL shortener website is a service that converts long website addresses into shorter, more manageable links. Users input a lengthy URL, and the website generates a condensed version, making it easier to share and remember.
The application interface consists of one page which contains:
- A form to shorten the URL, which takes two inputs:
- the long version of the url
- the alias of the url (defaults to a random string)
- A table which contains the previously shortened URLs.
- When a client tries to access the short URL, they should be redirected to the original long URL.
- If the client accesses a URL which doesn't exist, a
404error should be displayed. - There's no required authentication or authorization to generate short URLs.
- Node.js: Ensure Node.js is installed in your environment.
- npm: The Node.js package manager, npm, is used to manage dependencies.
To install the necessary dependencies, run:
npm installThis will install the packages listed in package.json.
Create a .env file in the root of your project to store environment-specific configurations, such as your database connection string and server port. Example:
MONGODB_URI = mongodb+srv://<username>:<password>@mongodburlhere
PORT= 8080To start the application, run:
node wwwThe application will be accessible at http://localhost:8080.