You know what is this about! This question is used thousands of times in design interviews. Here's the chance of actually doing it!
# The server should start at this port PORT=8080
If you use docker or docker-compose, this is the env used inside the container.
The server has the following endpoints.
The URL will be passed as a string in the HTTP request's body.
plain/text response with the shortened relative URL.
short-url is a URL generated from
short-url is invalid, returns a
Otherwise, the response should be a
302 with the expected original URL.
Do not try to call external service since your server will not have Internet service, in this task's setup.
$ curl -X POST -H "Content-Type: text/plain" -d 'https://www.google.com' 'http://localhost:8080/generate' 1 $ curl -I 'http://localhost:8080/follow/1' HTTP/1.1 302 Found X-Powered-By: Express Location: https://www.google.com Vary: Accept Content-Type: text/plain; charset=utf-8 Content-Length: 44 Date: Tue, 23 Jul 2019 21:01:54 GMT Connection: keep-alive
Submit to see your result!
Nobody here yet, solve it now to get on the board!