Create your own URL shortener REST-API and consume it using Vue.js
This is a REST-API based on NodeJS, Express and Mongo, to generate short URL's you need a place to store generated short url code with original URL and a server like nginx to match short url code with the original one
To run this project you will need nginx in order to resolve short URL's
Add following location inside your nginx.conf:
// Find 'api/route/$parameter' inside src/server/routes
location ~* "^/[0-9a-z@]{5,15}$" {
rewrite ^/(.*)$ http://localhost:8000/api/route/$1 redirect;
}
To get started locally, follow these instructions:
- If you haven't done it already, make a fork of this repo.
- Clone to your local computer using
git
. - Make sure that you have Node 10.9 or later installed. See instructions here.
- Make sure that you have
yarn
installed; see instructions here. - Run
yarn
(no arguments) from the root of your clone of this project. - Run
yarn link
to add all custom scripts we use to your global install.
Inside the cloned repo run
yarn run dev
The server will initialize using port 8000
Inside src you will finda very easy structure:
controllers
db
- models
server
- routes
app
server
To test API there is a Vue.js + Bootstrap project inside frontend folder. Check inside to find
controllers
components
- URLShortener
APIService.js
APIService is used to point API and resolve customer requests
Generate short URL
POST http://localhost:8000/api/create/url/
{
"baseUrl":"yourLongUR",
"shortBaseUrl":"the path to resolve the short URL"
}
Test and run docker to check if docker image will run properly URL shortener APP
- Vue.js - The web framework used
- Yarn - Dependency Management
- Valid URL - URI validation
- Short ID - Creation of short non-sequential url-friendly unique ids
- Daniel Chaur - Initial work
This project is licensed under the MIT License
- Personal growth
- Inspiration
- Self challenging