url.mob.bs is a URL shortening web service similar to bit.ly or TinyURL.
- Make sure you have
yarn
andnvm
installed nvm use && yarn
yarn start
- Build the Docker container with
docker build -t url.mob.bs:latest .
- Run the Docker container with
docker run -d -p 3000:3000 url.mob.bs:latest
These APIs require you to authenticate using the standard Authorization: Bearer base64(username:password)
scheme.
This can be done with curls -u
option (-u username:password
).
Create user
curl -X "POST" "http://localhost:3000/api/accounts/" \
-d $'{
"email": "email",
"password": "password"
}'
Get overall analytics
curl "http://localhost:3000/api/analytics" \
-u 'email:password'
Get analytics for an individual URL
curl "http://localhost:3000/api/analytics/SHORT_URL_ID" \
-u 'email:password'
Redirect to a long URL from a short URL ID
curl "http://localhost:3000/SOME_SHORT_URL_ID
Get all URLs
curl "http://localhost:3000/api/urls/" \
-u 'email:password'
Create new URL
curl -X "POST" "http://localhost:3000/api/urls/" \
-u 'email:password' \
-d $'{
"shortUrlId": "SOME_SHORT_URL_ID" # Optional
"longUrl": "http://mob.bs",
"expiration": "1619916173354" # Optional
}'
Get individual URL
curl "http://localhost:3000/api/urls/SOME_SHORT_URL_ID" \
-u 'email:password'
Delete individual URL
curl -X "DELETE" "http://localhost:3000/api/urls/eev5MgTE" \
-u 'email:password' \
.
├── Dockerfile -- Dockerfile for building and distributing the project
├── README.md -- General information
├── app/ -- app/ contains all the backend code for the application
├── app.ts -- app.ts is the entrypoint to the backend of the application
├── client/ -- client/ contains all of the frontend code for the application
├── ormconfig.json -- config file for TypeORM
├── package.json -- Contains build dependencies and scripts for both backend and frontend
├── public/ -- Contains the built frontend and base files (index.html)
├── tsconfig.json -- Contains Typescript configuration
└── yarn.lock -- Contains depency versions to lock dependencies
As _ has grown, so has its need to keep track of quickly referenced internal and external URLs. Having short or easily rememberable links to internal tools, wiki pages, and external resources has been seen as a useful resource over and over again. It's would also be nice to have a way to track utilization of the short URLs for reporting on engagement or just seeing how many people are actually using the link you made for others to use.
You've been asked to make an internal service for shortening URLs that anyone in the company can use. You can implement it in anyway you see fit, including whatever backend and frontend functionality that you think makes sense. Please try to make it both end user and developer friendly (so that we can integrate it with existing systems or chat bots, for example).
-
This URL shortener should have a well defined API for URLs created, including analytics of usage
-
URLs can be randomly generated (via any method you choose), or specified upon creation
-
No duplicate URLs are allowed to be created
-
Short links can not be easily enumerated
-
Short links can expire at a future time, or can live forever
-
Short links can be deleted
-
If a short link is created that was once deleted, it will have no "knowledge" of its previous version
-
This project should be able to be runnable locally within a docker container and some simple instructions
-
This project's documentation should include build and deploy instruction
-
Tests should be provided and able to be executed locally or within a test environment.