Bluh7 / URL-shortener-API

Just another URL shortener API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

URL-shortener-API

Description

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.

Installation

  1. Clone the repository
  2. Run npm install
  3. Setup PostgreSQL database as you can see in src/config/database.js
  4. Run npm run start

Usage

Create a short URL

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"
}

Get long URL from short URL

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"
}

Front-end

You can use the front-end to create a short URL. It is available at /.

License

MIT

About

Just another URL shortener API

License:MIT License


Languages

Language:JavaScript 80.7%Language:CSS 9.9%Language:EJS 9.5%