irevenko / url-shortener

✂️ Service for Shortening links using Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cherry URL Shortener ✂️

Red, Cherry 🍒 Themed Web Service for Shortening urls

How it works ❓

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

Technologies 🧾

  • Node.js
    • koa
    • shortid
    • mongoose
  • Tailwind CSS

Preview 🔍

Quick Start 🚀

git clone https://github.com/irevenko/url-shortener.git
cd url-shortener/src
npm install
touch .env (Add your variables)
node app.js

What I Learned 🧠

  • koa, koa-router, koa-bodyparser
  • ejs Engine
  • MongoDB

ToDo

  • Deploy on Heroku

License 📑

(c) 2020 Ilya Revenko. MIT License

About

✂️ Service for Shortening links using Node.js

License:MIT License


Languages

Language:JavaScript 100.0%