- This API converts a long website links to short (like goo.gl,bit.ly).
- Node.js
- NPM
- Express
-
Clone the project
-
Run given commands to the project directory
-
This command will install all require packages
npm install
- This command will start server in localhost and deploy the API on it (basically will run app.js file).
node app
- Now API is running on localhost. One can call the API from anywhere (like in own program or Postman), I am using cURL.
- User has to call the api with POST method at end-point api/shorten (call with JSON object, key name is fullURL and value is Website's Long Link)
- It will return the JSON object. In this object, "url" key has short url.
- Now insert "localhost:<port_number>/<short_url>" into browser and it will redirect it to original url.
- Keval S. Navadiya