DEV Community

Cover image for Shorten up huge URLs to a small link
Ishan Bagchi
Ishan Bagchi

Posted on

Shorten up huge URLs to a small link

Today I created a node app to get generate a small link for a long website link.

How to use:

Request

request

I am using Hoppscotch to play with my routes. You may use any tools like Hoppscotch, Postman, etc. Here I am creating a POST request to the URL https://ishan-us.herokuapp.com/api/url/shorten with content type application/json and a Parameter name longUrl with the value of any large URL you want to compress. That's it!!!

Response

response

View the response in a JSON format. you can see a response with status 200. The longUrl is the actual site where the user will be redirected, and the shortUrl is your generated small URL.

I automated the workflow of this project with GitHub Actions.

It was my first ever Actions so I was super duper excited. After clicking the Actions option in my repository, the below page appeared

Actions get started

I selected the set up your workflow yourself option to get started.

My Workflow

The name of my Github Actions is Node.js CI. It runs the following code every time something is pushed on the master branch, or if a pull request is made to the master branch.

npm ci
npm run build --if-present
npm test
Enter fullscreen mode Exit fullscreen mode

After I created my .yml file and ran my workflow, this page displayed after building.

build image

Submission Category:

Wacky Wildcards

Link to Code

@ishanbagchi/url-shortner

Note:

The collaboration to the project is open to all.

Top comments (2)

Collapse
 
spez profile image
Abhigyan

The date should be a timestamp.

Collapse
 
ishanbagchi profile image
Ishan Bagchi

Thanks for the idea.