An open API service indexing awesome lists of open source software.

https://github.com/ankurgel/reducto

Shortens URLs with a simple spell.
https://github.com/ankurgel/reducto

Last synced: 3 days ago
JSON representation

Shortens URLs with a simple spell.

Awesome Lists containing this project

README

        

Reducto
=======
A simple but performant and distributed URL shortener.

### API:
___Shorten URL___

----
Shortens provided URL and returns json data

* **URL**

/api/v1/shorten

* **Method:**

`POST`

* **Data Params**
**Required:**
`url=[string]`
**Optional:**
`custom=[string]`

* **Success Response:**

* **Code:** 201 Created

**Content:** `{"longUrl":"http://foobar.com","shortUrl":"http://localhost:8081/FPvYGy"}`

* **Error Response:**

* **Code:** 422 Unprocessable Entity

**Content:** `{ error : "User doesn't exist" }`

OR

* **Code:** 422 Unprocessable Entity

**Content:** `{"error":"URLValidationError: URL Domain is banned."}`

---
___Get Long URL___

----
Retrieves long URL and redirects

* **URL**

/:shortUrl

* **Method:**

`GET`

* **Path Params**
**Required:**
`shortUrl=[string]`

* **Success Response:**

* **Code:** 302 Moved Permanently

**Content:** `Moved Permanently.`

* **Error Response:**

* **Code:** 404 Not Found

**Content:** `{"error":"Error in getSlug for f00bar: record not found"}`

OR

* **Code:** 422 Unprocessable Entity

**Content:** `{"error":"URLValidationError: URL Domain is banned."}`

### Installation
#### Via Docker:
```
git clone [email protected]:AnkurGel/reducto.git
docker-compose up
$> curl --location --request POST 'http://localhost:8080/api/v1/shorten' --form 'url="https://github.com/AnkurGel/reducto"'
```

### Development
* `cp config.yml.sample config.yml`
* Edit `config.yml`
* Create relevant database
* Add banned hosts in the redis manually like:
   `SADD urlBannedSet bit.ly tinurl.com tiny.one t.co rotf.lol goo.gl fb.me`
* Run keygen: `REDUCTO_CONFIG_PATH=config.yml go run cmd/reducto-keygen/main.go`
* Run server: `REDUCTO_CONFIG_PATH=config.yml go run cmd/reducto-server/main.go`