DEV Community

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

Posted on

2 1

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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (2)

Collapse
 
spez profile image
Abhigyan β€’

The date should be a timestamp.

Collapse
 
ishanbagchi profile image
Ishan Bagchi β€’

Thanks for the idea.

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free β†’