id
- short_code
conversion is just a conversion into another base numeral system (in this case base-62), where each value 0-61 is mapped onto an alphabet.
The initial CHARACTERS
array is shuffled with fixed RNG based on secret_key_base
, so it persists between launches, and forms an alphabet.
short_code
itself is not populated into the database. It is being calculated based on ShortUrl#id
and vice versa.
docker-compose build
docker-compose up mariadb
docker-compose run url-shortener-app rails db:migrate
docker-compose -f docker-compose-test.yml build
docker-compose run url-shortener-app rails db:migrate
docker-compose -f docker-compose-test.yml run url-shortener-rspec rails db:test:prepare
docker-compose -f docker-compose-test.yml run url-shortener-rspec
docker-compose up
curl -X POST -d "full_url=https://google.com" http://localhost:3000/short_urls.json
curl localhost:3000
curl -I localhost:3000/abc