Skip to content
Switch branches/tags
Go to file

URL Shortener Microservice 💙

This service accepts a URL as a parameter and will check whether it follows the valid format. If the URL is valid, it will return both the original URL and shortened URL in the JSON response. If it is not valid, the JSON response will contain an error instead. When you visit that shortened URL, it will redirect you to the original link.

You can test it at

A Full Stack Javascript application built using MongoDB, Node.js and Express. An API Project for FreeCodeCamp.

Example Creation Usage

Pass the URL to path[URL] as below:

Valid URL example

Invalid URL example (missing protocol)

Example Creation Output

Valid URL example JSON response output

  original_url: "",
  shortened_url: ""


Visiting the shortened URL: will redirect to:

To Run Project Locally


In order to run this project locally, you should have the following installed:

Installation & Startup

  1. Fork this repo

  2. Clone the fork

  3. Install Dependencies: $ npm install

  4. Run your MongoDB server: $ mongod --port 27017 --dbpath=./data

    Note: Your mongoDB is now running at: mongodb://localhost:27017/<your_database_name>

  5. Add a .env file to your project's root directory and set MONGO_CONNECTION_STRING to mongodb://localhost:27017/<your_database_name>

  6. Start the Server: $ node app.js

  7. Visit http://localhost:3000/

Enjoy! 💙


A Fullstack JavaScript application that creates shortened URLs 💙




No releases published


No packages published