The JS app "Short URL" holds a collection of URLs, accessible with a short code:
- Add a new URL -> generates a short URL
- Redirect by short URL to the original URL
- Statistics: URL | Short URL | Date Created | Visits
The app is based on Node.js + Express.js + Pug.
- It has no database and app data is not persistent!
Demo:
- Web app live demo: https://shorturl.nakov.repl.co
- RESTful API live demo: https://shorturl.nakov.repl.co/api
- Play with the code at: https://repl.it/@nakov/shorturl
The following endpoints are supported:
GET /api
- list all API endpointsGET /api/urls
- list all shout URLsGET /api/urls/:shortCode
- finds short URL by givenshortCode
POST /api/urls
- create a new URL shortcode (post a JSON objects in the request body, e.g.{"url":"https://cnn.com", "shortCode":"cnn"}
DELETE /api/urls/:shortCode
- deletes short URL by givenshortCode
POST /api/urls/visit/:shortCode
- visits short URL by givenshortCode
(increases the visits count)