Edlavio / url-shortener-microservice

URL Shortener Microservice made during FreeCodeCamp Back End Development and APIs course.

Home Page:https://url-shortener-uzv4.onrender.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

url-shortener-microservice

A Url shortener microservice made during FreeCodeCamp Back End Development and APIs course.

Test sucess image

Test Scenario:

  • Use dns module
  • Post a url in /api/shorturl and get a response with original_url and short_url
  • When you visit /api/shorturl/<short_url>, you will be redirected to the original URL.
  • If you pass an invalid URL need return { error: 'invalid url' }

Helpful resources

How test

You have 2 example of request in app.http you could use REST Client ou another tool.

Shorten url request:

POST
https://url-shortener-uzv4.onrender.com/api/shorturl
Content-Type: application/x-www-form-urlencoded

// A url form encoded
url=https://edlavio.eu.org

Getting shortened url:

GET

// After shorturl/put_here_short_url
https://url-shortener-uzv4.onrender.com/api/shorturl/534447

// Open in Browser and will redirect to https://github.com/Edlavio

How setup

You will need pnpm and Node.js and some API test tool (Postman, Imsomnia, Thunder Client, Httpie or REST Client).

You will need also setup a Mongo Database and create a .env file you have .env.sample as example.

# To install the dependencies
pnpm i
# To run de project
pnpm dev

About

URL Shortener Microservice made during FreeCodeCamp Back End Development and APIs course.

https://url-shortener-uzv4.onrender.com


Languages

Language:JavaScript 90.5%Language:HTML 9.5%