{"id":14955435,"url":"https://github.com/yukitas/rails-rest-api","last_synced_at":"2025-09-30T13:30:50.123Z","repository":{"id":39664355,"uuid":"126522257","full_name":"YuKitAs/rails-rest-api","owner":"YuKitAs","description":"A simple RoR 6 REST API demo with JWT authentication.","archived":false,"fork":false,"pushed_at":"2024-05-17T19:13:10.000Z","size":182,"stargazers_count":31,"open_issues_count":1,"forks_count":18,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-14T11:14:12.783Z","etag":null,"topics":["github-actions","jwt","rails","rails6","rest-api","restful","ruby","ruby-on-rails","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YuKitAs.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":"2018-03-23T18:05:43.000Z","updated_at":"2024-10-15T04:14:25.000Z","dependencies_parsed_at":"2024-01-18T15:56:28.998Z","dependency_job_id":"3f306c64-4ed4-4a11-80e2-bf7946cafa49","html_url":"https://github.com/YuKitAs/rails-rest-api","commit_stats":{"total_commits":106,"total_committers":3,"mean_commits":"35.333333333333336","dds":0.339622641509434,"last_synced_commit":"a5bc4b5ade893071403052b24ffb0e2054087769"},"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YuKitAs%2Frails-rest-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YuKitAs%2Frails-rest-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YuKitAs%2Frails-rest-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YuKitAs%2Frails-rest-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YuKitAs","download_url":"https://codeload.github.com/YuKitAs/rails-rest-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234737847,"owners_count":18879180,"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":["github-actions","jwt","rails","rails6","rest-api","restful","ruby","ruby-on-rails","sqlite3"],"created_at":"2024-09-24T13:11:09.221Z","updated_at":"2025-09-30T13:30:44.821Z","avatar_url":"https://github.com/YuKitAs.png","language":"Ruby","readme":"![example workflow](https://github.com/YuKitAs/rails-rest-api/actions/workflows/rubyonrails.yml/badge.svg?branch=master)\n\n# Rails Rest API\n\n## Project Setup\n\n**Install all gems**:\n\n```console\n$ bundle install\n```\n\n**Update the database with new data model**:\n\n```console\n$ rake db:migrate\n```\n\n**Feed the database with default seeds**:\n\n```console\n$ rake db:seed\n```\n\n**Start the web server on `http://localhost:3000` by default**:\n\n```console\n$ rails server\n```\n\n**Run all RSpec tests and Rubocop**:\n\n```console\n$ rake test\n```\n\n## Usage\n\n| HTTP verbs | Paths  | Used for |\n| ---------- | ------ | --------:|\n| POST | /register| Create a user|\n| POST | /login   | Authenticate a user |\n| GET | /posts    | List all posts|\n| GET | /posts/:post_id | Show a single post |\n| POST | /posts | Create a post |\n| PUT | /posts/:post_id | Update a post |\n| DELETE | /posts/:post_id | Delete a post |\n| GET | /posts/:post_id/comments | List all comments of a post |\n| GET | /posts/:post_id/comments/:comment_id | Show a single comment |\n| POST | /posts/:post_id/comments | Create a comment |\n| PUT | /posts/:post_id/comments/:comment_id | Update a comment |\n| DELETE | /posts/:post_id/comments/:comment_id | Delete a comment |\n\n## Use Case Examples\n\n### Authentication\n\n**Create a new user**:\n\n```console\n$ curl -X POST -H 'Content-type: application/json' -d '{\"email\": \"testuser@email.com\", \"password\": \"testuser123\"}' localhost:3000/register\n```\n\n**Authenticate a user**:\n\n```console\n$ curl -X POST -H 'Content-type: application/json' -d '{\"email\": \"testuser@email.com\", \"password\": \"testuser123\"}' localhost:3000/login\n```\n\nOn successful login, `{\"auth_token\": \u003ctoken\u003e}` will be returned. This token will be expired after 24 hours.\n\n### CRUD\n\n**In order to access the posts and comments, add `-H 'Authorization: \u003ctoken\u003e'` to the header of every request for CRUD operations.**\n\nThe `create`, `update` and `delete` actions can only be executed by users authorized on admin. A default admin user is definded in `db/seeds.rb`. After seeding the database, `{\"email\": \"admin@email.com\", \"password\": \"admin123\"}` can be used to login as an admin.\n\n**Create a new post**:\n\n```console\n$ curl -X POST -H 'Content-type: application/json' -d '{\"title\": \"My title\", \"content\": \"My content\"}' localhost:3000/posts\n```\n\n**Create a new comment**:\n\n```console\n$ curl -X POST -H 'Content-type: application/json' -d '{\"name\": \"YuKitAs\", \"message\": \"My message\"}' localhost:3000/posts/1/comments\n```\n\nThe `name` field is optional with default value `anonym`.\n\n**Update an existing post by id**:\n\n```console\n$ curl -X PUT -H 'Content-type: application/json' -d '{\"title\": \"My new title\", \"content\": \"My new content\"}' localhost:3000/posts/1\n```\n\n**Update an existing comment by id**:\n\n```console\n$ curl -X PUT -H 'Content-type: application/json' -d '{\"name\": \"YuKitAs\", \"message\": \"My new message\"}' localhost:3000/posts/2/comments/1\n```\n\n**Delete an existing post by id**:\n\n```console\n$ curl -X DELETE localhost:3000/posts/1\n```\n\nAll the comments of this post will be deleted as well.\n\n**Delete an existing comment by id**:\n\n```console\n$ curl -X DELETE localhost:3000/posts/2/comments/1\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyukitas%2Frails-rest-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyukitas%2Frails-rest-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyukitas%2Frails-rest-api/lists"}