This is a URL shortener API. It takes a long URL and returns a short URL. When the short URL is visited, it redirects to the long URL.
- Clone the repository
- Run
npm install
- Setup PostgreSQL database as you can see in
src/config/database.js
- Run
npm run start
Send a POST request to /api/v1/url/shorten
with a JSON body containing the long URL.
Example:
{
"url": "https://www.github.com"
}
Response:
{
"shortUrl": "http://localhost:3000/V8E4X",
"shortUrlCode": "V8E4X"
}
Send a GET request to /api/v1/url/shorten/:code
where :code
is the short URL code.
Example:
GET /api/v1/url/shorten/V8E4X
Response:
{
"url": "https://www.github.com"
}
You can use the front-end to create a short URL. It is available at /
.