- Clone the repository by running the following command
$ git clone git@github.com:chaharshivam/url-shortner.git
- Now, go to the cloned directory
$ cd url-shortner
- Install dependencies by running the following commands
$ yarn install --check-files
$ bundle i
- Setup the database
$ rails db:create db:migrate db:setup
- Now create a
env
file withROOT_URL
$ touch .env
$ echo "ROOT_URL=http://localhost:3000" > .env
- Now we can run the rake tasks as follows
$ URL=https://bigbinary.com/jobs bundle exec rake app:encode
$ SHORTURL=https://short.is/tkLo2367 bundle exec rake app:decode
App is deployed here
urls
table should have a boolean fieldpinned
with a default value offalse
- The urls returned at
index
action are in the following order:- Pinned urls in chronological order i.e. The latest pinned url is at the top
- Non-Pinned urls in chronological order but after the pinned urls
index:
method: 'GET'
path: '/'
responses:
200: Returns a list of urls
404: Not Found
422: Unprocessable Entity
create:
method: 'POST'
path: '/urls'
parameters:
url:
original: 'original url e.g. https://bigbinary.com'
responses:
200: Returns the url with shortened link
422: Unprocessable Entity
show:
method: 'GET'
path: '/urls/:slug'
parameters:
slug: unique slug
responses:
200: Returns the url object with original url
404: Not Found
update:
method: 'PUT'
path: '/urls/:slug'
parameters:
slug: unique slug
url:
pinned: 'true/false'
responses:
200: Returns the updated url
404: Not Found
422: Unprocessable Entity