Red, Cherry 🍒 Themed Web Service for Shortening urls
For example: we have our inital link which we need to short - github.com
And we have our domen which is for instance - short.me
We generate a unique token for our URL and save it into DB. In my case i used shortid library to generate it for me
And we get a token - 1kDdvurHW
. Then we have to hookup this token to our domen
After this we compose our short URL by adding token after domen - short.me/1kDdvurHW
If URL is in DB we return it to user, Else we just create a new one by assembling our domen
and token
together.
Finally when user enters this URL we redirect him to our initial site by checking the token from the DB and comparing it to our URL. short.me/1kDdvurHW -> github.com
So our DB Schema has URL collection which contains: Full URL, URL Token, Short URL
And we store our Full URL together with unique URL Token
git clone https://github.com/irevenko/url-shortener.git
cd url-shortener/src
npm install
touch .env (Add your variables)
node app.js
(c) 2020 Ilya Revenko. MIT License