mhero / rails-okr-api

OKR simulator API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dependencies

  • Ruby 3.2.2
  • Node >= 17.4.0

Apps info

  • Rails app runs in port 4567 (using this default config)
  • React app runs in port 8084 (using this default config)

Local Development

Docker install

  1. Install dependencies
https://www.docker.com/products/docker-desktop
  1. Clone repository

  2. cd into repository folder

  3. Create env files for rails and react (replace variables with credentials and server variables)

cp .env.example .env
cp ./okr-react/.env.example ./okr-react/.env
  1. Run
docker-compose up
  1. Rails debug
docker exec -it $( docker ps | grep rails-okr-api | awk "{print \$1}" | head -n 1 ) rails c

Full install

  1. Install dependencies
brew install node
\curl -sSL https://get.rvm.io | bash
rvm install "ruby-3.2.2"
rvm use 3.2.2
brew install postgresql
  1. Clone repository

  2. cd into repository folder

  3. Run in command line next:

gem install bundler && bundle config jobs 7
  1. Create env files for rails and react (replace variables with credentials and server variables)
cp .env.example .env
cp ./okr-react/.env.example ./okr-react/.env
  1. Replace file with credentials of local postgres db(in development section)
database.yml
  1. Run in command line next:
bundle install
cd okr-react && npm install
  1. Setup db:
rails db:create
rails db:migrate

you can also seed data:

rails db:seed
  1. run backend (on aterminal window)
rails server --binding 0.0.0.0 --port 4567
  1. run sidekiq (on aterminal window)
bundle exec sidekiq
  1. run frontend (on a different terminal window)
cd okr-react && npm run dev

Request example

Before run:

brew install jq

then:

token=$(curl -d '{"username":"random", "password":"letmein1"}'  -H "Content-Type: application/json" -X POST http://localhost:3000/authenticate | jq --raw-output '.auth_token')
curl --location --request GET 'http://localhost:3000/goals?page=1' \
--header "Authorization: $token" \
--header "Content-Type: application/json"
curl --location --request POST 'http://localhost:3000/goals/1/key_results' \
--header 'Content-Type: application/json' \
--header "Authorization: $token" \
--data-raw '{
    "key_result": {
        "title": "Test"
    }
}'

About

OKR simulator API

License:Apache License 2.0


Languages

Language:Ruby 73.0%Language:JavaScript 12.6%Language:Shell 6.8%Language:CSS 4.7%Language:HTML 2.5%Language:Dockerfile 0.4%