{"id":15151484,"url":"https://github.com/waihon/library-api","last_synced_at":"2026-01-19T09:01:42.577Z","repository":{"id":80035287,"uuid":"425904906","full_name":"waihon/library-api","owner":"waihon","description":"https://elibapi.herokuapp.com - The Library API developed using Ruby on Rails 6 and JSON:API as part of Full Stack Ember with Rails course.","archived":false,"fork":false,"pushed_at":"2021-12-21T08:26:51.000Z","size":103,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T09:42:59.607Z","etag":null,"topics":["postgresql","rails","rails6","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/waihon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-11-08T16:06:12.000Z","updated_at":"2021-12-21T08:26:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"8ce5f6b9-d4d4-4302-acba-72726a9a8ac1","html_url":"https://github.com/waihon/library-api","commit_stats":{"total_commits":91,"total_committers":1,"mean_commits":91.0,"dds":0.0,"last_synced_commit":"5628c79a8279d8f5ee946287f4198851310b7a00"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/waihon/library-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waihon%2Flibrary-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waihon%2Flibrary-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waihon%2Flibrary-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waihon%2Flibrary-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/waihon","download_url":"https://codeload.github.com/waihon/library-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waihon%2Flibrary-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28565001,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T08:53:44.001Z","status":"ssl_error","status_checked_at":"2026-01-19T08:52:40.245Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["postgresql","rails","rails6","ruby"],"created_at":"2024-09-26T15:03:45.988Z","updated_at":"2026-01-19T09:01:42.559Z","avatar_url":"https://github.com/waihon.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# README\n\nThis README would normally document whatever steps are necessary to get the\napplication up and running.\n\nThings you may want to cover:\n\n* Ruby version\n\n* System dependencies\n\n* Configuration\n\n* Database creation\n\n* Database initialization\n\n* How to run the test suite\n\n* Services (job queues, cache servers, search engines, etc.)\n\n* Deployment instructions\n\n* ...\n\n## Terminal Commands\n\n### 3. Creating a Rails Project\n\n* `rails new library-api --api`\n* `cd library-api`\n* `bundle install`\n* `bin/rails server`\n\n### 7. Rails: JSON API Resource Basics\n\n* `bin/rails g migration CreateAuthors`\n* `bin/rails db:migrate`\n\n### 23. Ruby Author Filter\n\n* `bin/rails db:seed:replant`\n\n### 25 Rails Book Resource\n\n* `bin/rails g model book title:string isbn:string publish_date:date author:references`\n* `bin/rails g controller books`\n* `bin/rails g jsonapi:resource book`\n* `bin/rails db:migrate`\n\n### 34. Rails Reviews Resource\n\n* `bin/rails g model review user:string body:text book:references`\n* `bin/rails g controller reviews`\n* `bin/rails db:migrate`\n* `bin/rails g jsonapi:resource reviews`\n\n### 40. Storing Users Securely with BCrypt\n\n* `bundle install` (after updating Gemfile)\n* `bin/rails g model user email:string username:string password_digest:string`\n* `bin/rails db:migrate`\n\n### 41. Creating Sessions with JWTs\n\n* `bundle install` (after updating Gemfile)\n* `bin/rails secret` (to generate a secret string)\n\n### 47. Adding Authorization to Create APIs\n\n#### Terminal\n* `bin/rails g migration AddUserIdToAuthors user:references`\n* `bin/rails g migration AddUserIdToBooks user:references`\n* `bin/rails db:migrate`\n\n#### Rails Console\n* `Author.update_all(user_id: 1)`\n* `Book.update_all(user_id: 1`)\n\n### 48. Adding Computed Attributes to APIs\n\n#### Terminal\n* `bin/rails g migration AddUserIdToReviews user:references`\n* `bin/rails db:migrate`\n* `bin/rails db:rollback`\n* `bin/rails db:migrate` (after editing the latest migration file)\n* `bundle install` (after updating Gemfile to use jsonapi-resources 0.9)\n\n#### Rails Console\n\n* `Review.update_all(user_id: 1)`\n\n### 54 Deploying Rails with Heroku\n\n#### Terminal\n* `sqlite3 db/development.sqlite3 -csv -header 'SELECT * FROM users;' \u003e db/users.csv`\n* `sqlite3 db/development.sqlite3 -csv -header 'SELECT * FROM authors;' \u003e db/authors.csv`\n* `sqlite3 db/development.sqlite3 -csv -header 'SELECT * FROM books;' \u003e db/books.csv`\n* `sqlite3 db/development.sqlite3 -csv -header 'SELECT * FROM reviews;' \u003e db/reviews.csv`\n* `bin/rails db:create`\n* `bin/rails db:migrate`\n* `psql -d library-api -c \"copy users from '$(pwd)/db/users.csv' CSV HEADER\"`\n* `psql -d library-api -c \"copy authors from '$(pwd)/db/authors.csv' CSV HEADER\"`\n* `psql -d library-api -c \"copy books from '$(pwd)/db/books.csv' CSV HEADER\"`\n* `psql -d library-api -c \"copy reviews from '$(pwd)/db/reviews.csv' CSV HEADER\"`\n\n#### PostreSQL\n* `SELECT setval('users_id_seq', (SELECT MAX(id) FROM users));`\n* `SELECT setval('authors_id_seq', (SELECT MAX(id) FROM authors));`\n* `SELECT setval('books_id_seq', (SELECT MAX(id) FROM books));`\n* `SELECT setval('reviews_id_seq', (SELECT MAX(id) FROM reviews));`\n\n#### Heroku\n* `heroku create elibapi`\n* `git push heroku main`\n* `heroku config:set JWT_SECRET=$(rails secret)`\n* `heroku addons:create heroku-postgresql:hobby-dev`\n* `heroku pg:push library-api DATABASE_URL`\n* `heroku open`\n* `heroku pg:reset`\n* `heroku run \"rails db:migrate\"`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaihon%2Flibrary-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwaihon%2Flibrary-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaihon%2Flibrary-api/lists"}