{"id":22946575,"url":"https://github.com/kfox/example-rails5-rest-api","last_synced_at":"2025-07-09T08:02:56.642Z","repository":{"id":91416891,"uuid":"84154254","full_name":"kfox/example-rails5-rest-api","owner":"kfox","description":"An example RESTful API using Rails 5 API mode","archived":false,"fork":false,"pushed_at":"2017-06-19T16:38:00.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-07T14:45:40.070Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kfox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-07T04:22:20.000Z","updated_at":"2017-03-07T04:29:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"e1faa65f-3960-4cec-9e46-e61fc48d5426","html_url":"https://github.com/kfox/example-rails5-rest-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfox%2Fexample-rails5-rest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfox%2Fexample-rails5-rest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfox%2Fexample-rails5-rest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kfox%2Fexample-rails5-rest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kfox","download_url":"https://codeload.github.com/kfox/example-rails5-rest-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246724595,"owners_count":20823542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-14T14:47:20.371Z","updated_at":"2025-04-01T22:40:26.912Z","avatar_url":"https://github.com/kfox.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example RESTful API using Rails 5 in API mode\n\n## Notes\n\n* Webhook calls aren't actually executed, but they will be logged\n  in the Rails server output.\n\n* Do NOT use this code for production since the\n  application secrets are stored in the repository.\n\n## Running the application using Docker and docker-compose\n\nThese instructions are for MacOS.\n\n### Installing required packages using Homebrew\n\n1. `brew cask install virtualbox`\n2. `brew install docker docker-compose docker-machine`\n\n### Building and running the application in the background\n\n1. `docker-compose up -d`\n2. `docker-compose run api rails db:setup db:migrate`\n\n### Tailing the logs\n\n`docker-compose logs -f -t`\n\n### Determining the IP address of the API\n\n`docker-machine ip default`\n\nThe API will be listening on port 80 inside the Docker container.\n\n### Running the Rails console in the Docker environment\n\n`docker-compose run api rails c`\n\n### Stopping Docker and deleting old local images\n\n`docker-compose down --rmi local`\n\n## Local Development Setup\n\n1. `brew install rbenv rbenv-binstubs ruby-build postgresql`\n2. Initialize postgres per instructions.\n3. `eval \"$(rbenv init -)\" \u0026\u0026 rbenv install 2.4.1 \u0026\u0026 rbenv local 2.4.1`\n4. `gem install rails bundler`\n5. `rails db:setup db:migrate`\n6. `rails s -d`\n\n### Inspect the available API routes\n\n`rake routes`\n\n## Curl command examples\n\n*NOTE:* Replace `localhost:3000` in the examples below with `localhost`\nif you are running the API in the Docker container.\n\nFor prettier (i.e., readable) output:\n1. Install [jq](https://stedolan.github.io/jq/), e.g. `brew install jq`\n2. Add the `-s` flag to the `curl` commands below\n3. Pipe the output of each `curl` command to `jq .`\n\n### Obtain a JSON Web Token (JWT)\n\n`curl -XPOST -H \"Content-type: application/json\" -d '{\"auth\": {\"email\": \"admin@example.com\", \"password\": \"password\"}}' 'http://localhost:3000/user_token'`\n\nReplace the string `YOUR_TOKEN_HERE` in the examples below with the\ntoken received from the response.\n\n### Get a list of brands\n\n`curl -XGET -H 'Authorization: Bearer YOUR_TOKEN_HERE' -H \"Content-type: application/json\" 'http://localhost:3000/brands'`\n\n### Get a specific brand\n\n`curl -XGET -H 'Authorization: Bearer YOUR_TOKEN_HERE' -H \"Content-type: application/json\" 'http://localhost:3000/brands/SOME-BRAND-UUID'`\n\n### Add a new brand\n\n`curl -XPOST -H 'Authorization: Bearer YOUR_TOKEN_HERE' -H \"Content-type: application/json\" -d '{\"name\": \"Acme Towels\"}' 'http://localhost:3000/brands'`\n\n### Remove a brand\n\n`curl -XDELETE -H 'Authorization: Bearer YOUR_TOKEN_HERE' -H \"Content-type: application/json\" 'http://localhost:3000/brands/SOME-BRAND-UUID'`\n\n### Get a list of consumers\n\n`curl -XGET -H 'Authorization: Bearer YOUR_TOKEN_HERE' -H \"Content-type: application/json\" 'http://localhost:3000/consumers'`\n\n### Get a specific consumer\n\n`curl -XGET -H 'Authorization: Bearer YOUR_TOKEN_HERE' -H \"Content-type: application/json\" 'http://localhost:3000/consumers/SOME-CONSUMER-UUID'`\n\n### Get a list of brand affinities for a given consumer\n\n`curl -XGET -H 'Authorization: Bearer YOUR_TOKEN_HERE' -H \"Content-type: application/json\" 'http://localhost:3000/consumers/SOME-CONSUMER-UUID/brand_affinities'`\n\n### Add an affinity for one (or more) brands to a consumer\n\n`curl -XPUT -H 'Authorization: Bearer YOUR_TOKEN_HERE' -H \"Content-type: application/json\" -d '{\"brand_affinity_ids\": [ \"SOME-BRAND-UUID\", \"ANOTHER-BRAND-UUID\" ]}' 'http://localhost:3000/consumers/SOME-CONSUMER-UUID'`\n\n### Remove a consumer\n\n`curl -XDELETE -H 'Authorization: Bearer YOUR_TOKEN_HERE' -H \"Content-type: application/json\" 'http://localhost:3000/consumers/SOME-CONSUMER-UUID'`\n\n### Change a brand's list of followers\n\n`curl -XPUT -H 'Authorization: Bearer YOUR_TOKEN_HERE' -H \"Content-type: application/json\" -d '{\"follower_ids\": [ \"SOME-FOLLOWER-UUID\", \"ANOTHER-FOLLOWER-UUID\" ]}' 'http://localhost:3000/brands/SOME-BRAND-UUID'`\n\n### Get a list of webhooks\n\n`curl -XGET -H 'Authorization: Bearer YOUR_TOKEN_HERE' -H \"Content-type: application/json\" 'http://localhost:3000/hooks'`\n\n### Add a new webhook\n\n`curl -XPOST -H 'Authorization: Bearer YOUR_TOKEN_HERE' -H \"Content-type: application/json\" -d '{\"threshold\": \"50\", \"callback\": \"https://foo.example.com/bar\"}' 'http://localhost:3000/hooks'`\n\n### Remove a webhook\n\n`curl -XDELETE -H 'Authorization: Bearer YOUR_TOKEN_HERE' -H \"Content-type: application/json\" 'http://localhost:3000/hooks/SOME-WEBHOOK-UUID'`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkfox%2Fexample-rails5-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkfox%2Fexample-rails5-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkfox%2Fexample-rails5-rest-api/lists"}