Brandon Hoult (bhoult@gmail.com)
$ sudo apt-get install postgresql git libpq-dev git
$ sudo -u postgres psql
# create user USERNAME with password PASSWORD;
# create database USERNAME;
# create role testapp with createdb login password 'asdkjfhr932485r7';
# ALTER USER USERNAME CREATEDB;
$ rvm get head
$ rvm install ruby-3.1.1
Instructions for rvm are included in the above link, but there are many alternitive ways to install ruby... just make sure it is at least version 3.1.1
$ git clone https://bhoult@bitbucket.org/bhoult/testapp.git
$ cd testapp
$ gem install rails
$ rm Gemfile.lock
$ bundle install
$ rails db:migrate:reset; rails db:seed
$ rails test
$ rails s -b 0.0.0.0
Then point your web browser to localhost:3000
To interact with the api you will need to generate a JSON Web Token. This is a bearer token that needs to be included in the header of any api requests.
To simplify it a bit you can also include it in GET requests from the browser the token in the below example should work for the default user.
http://localhost:3000/statuses?bearer=eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxfQ._fY8DlihYIcYLaTI2BRNSpcErBudi8r-MGENoLGvJy8
To login as a user and retrieve the token you can do the following from the command line
$ curl -X POST localhost:3000/users/login -H 'Content-Type: application/json' -d '{"username":"admin","password":"test"}'| json_pp
If you wish to containerize this application there is a Dockerfile included in the root folder to get you started.
There are example CURL calls for each api located in the source code under app/controllers. The varous api calls are further documented below: