This problem was proposed at one programming test I've took part. I was asked to build one API which reduces URLs and when accessed by that shortened url, it should redirect the user into the original URL.
Simply run:
> yarn or npm install
Then you can run the server with:
> yarn server or npm run server
Server will be listening into http://localhost:3333
-
POST Route: {{ BASE_URL }}/short
It expect to receive one { url: string } on the request.body.
It returns { url: string } on the response.body, which is the shortened URL. -
GET Route: {{ BASE_URL }}/:hash
It will redirect you to the originalUrl through your shortened link. -
The app have one GET Route: {{ BASE_URL }}/shortened/all
It will return one array with all shortened links.
OBS: The api only uses memory storage, so every shortened link will be lost on server reset.
OBS-2: On the project repository, you will find a file called "insomnia_routes.json" in which you can export to get two Insomnia HTTP Routes, so you can test the app more easily.
Email: regisprogramming@gmail.com
LinkedIn Profile
GitHub Profile
GitLab Profile