All Projects → YuKitAs → rails-rest-api

YuKitAs / rails-rest-api

Licence: GPL-3.0 license
A simple RoR 5 REST API demo with JWT authentication.

Programming Languages

ruby
36898 projects - #4 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to rails-rest-api

LocalSupport
A directory of local support services and volunteer opportunities
Stars: ✭ 60 (+140%)
Mutual labels:  travis-ci, rails5, ruby-on-rails
activeadmin active resource
Active Admin + Active Resource: to use a REST API in place of a local database as data source
Stars: ✭ 20 (-20%)
Mutual labels:  rails5, ruby-on-rails
Activeadmin froala editor
Froala WYSIWYG editor for ActiveAdmin
Stars: ✭ 30 (+20%)
Mutual labels:  rails5, ruby-on-rails
katapult
Kickstart Rails development!
Stars: ✭ 21 (-16%)
Mutual labels:  rails5, ruby-on-rails
Dashvis
An open-source Dashboard built for users, to organize their resources via Tables and Folders.
Stars: ✭ 31 (+24%)
Mutual labels:  rails5, ruby-on-rails
Reactchat
A chat app built with React.js and ActionCable in Ruby on Rails 5.1
Stars: ✭ 90 (+260%)
Mutual labels:  rails5, ruby-on-rails
Websiteone
A website for Agile Ventures
Stars: ✭ 132 (+428%)
Mutual labels:  rails5, ruby-on-rails
full-stack-web-developer
🔥 Roadmap to become a Full Stack Web Developer. What? Why? How?
Stars: ✭ 76 (+204%)
Mutual labels:  ruby-on-rails
ci-configuration-examples
This repository makes it easy to run your MATLAB tests on some of the most common CI platforms. The configuration files take care of setting up MATLAB and automatically executing your MATLAB tests.
Stars: ✭ 52 (+108%)
Mutual labels:  travis-ci
premiere
A simple way to consume APIs with Javascript.
Stars: ✭ 67 (+168%)
Mutual labels:  restful
ui bibz
Ui Framework based on Bootstrap and Ruby on Rails
Stars: ✭ 13 (-48%)
Mutual labels:  ruby-on-rails
terraform-aws-s3-bucket
Terraform module that creates an S3 bucket with an optional IAM user for external CI/CD systems
Stars: ✭ 138 (+452%)
Mutual labels:  travis-ci
firebase id token
A Ruby gem to verify the signature of Firebase ID Tokens.
Stars: ✭ 138 (+452%)
Mutual labels:  ruby-on-rails
remove emoji
2021 Ruby Remove Emoji 😈🈲😱 for Ruby 2.x ~ 3.0 / Rails 4、5.x、6.x
Stars: ✭ 54 (+116%)
Mutual labels:  ruby-on-rails
react-devise-token-auth-sample
React on Rails using devise_token_auth for authentication
Stars: ✭ 25 (+0%)
Mutual labels:  rails5
go-zero
A cloud-native Go microservices framework with cli tool for productivity.
Stars: ✭ 23,294 (+93076%)
Mutual labels:  restful
router
An Fully Automatic RESTful PHP Router
Stars: ✭ 51 (+104%)
Mutual labels:  restful
LiDeploy
🚀 A DigitalOcean Reseller written with Ruby On Rails
Stars: ✭ 20 (-20%)
Mutual labels:  ruby-on-rails
octopub
Publish data easily, quickly and correctly
Stars: ✭ 41 (+64%)
Mutual labels:  ruby-on-rails
REST API Test Framework Python
REST API Test Framework example using Python requests and flask for both functional and performance tests.
Stars: ✭ 43 (+72%)
Mutual labels:  restful

Build Status

Rails Rest API

Project Setup

Install all gems:

$ bundle install

Update the database with new data model:

$ rake db:migrate

Feed the database with default seeds:

$ rake db:seed

Start the web server on http://localhost:3000 by default:

$ rails server

Run all RSpec tests and Rubocop:

$ rake test

Usage

HTTP verbs Paths  Used for
POST /register Create a user
POST /login Authenticate a user
GET /posts List all posts
GET /posts/:post_id Show a single post
POST /posts Create a post
PUT /posts/:post_id Update a post
DELETE /posts/:post_id Delete a post
GET /posts/:post_id/comments List all comments of a post
GET /posts/:post_id/comments/:comment_id Show a single comment
POST /posts/:post_id/comments Create a comment
PUT /posts/:post_id/comments/:comment_id Update a comment
DELETE /posts/:post_id/comments/:comment_id Delete a comment

Use Case Examples

Authentication

Create a new user:

$ curl -X POST -H 'Content-type: application/json' -d '{"email": "[email protected]", "password": "testuser123"}' localhost:3000/register

Authenticate a user:

$ curl -X POST -H 'Content-type: application/json' -d '{"email": "[email protected]", "password": "testuser123"}' localhost:3000/login

On successful login, {"auth_token": <token>} will be returned. This token will be expired after 24 hours.

CRUD

In order to access the posts and comments, add -H 'Authorization: <token>' to the header of every request for CRUD operations.

The 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": "[email protected]", "password": "admin123"} can be used to login as an admin.

Create a new post:

$ curl -X POST -H 'Content-type: application/json' -d '{"title": "My title", "content": "My content"}' localhost:3000/posts

Create a new comment:

$ curl -X POST -H 'Content-type: application/json' -d '{"name": "YuKitAs", "message": "My message"}' localhost:3000/posts/1/comments

The name field is optional with default value anonym.

Update an existing post by id:

$ curl -X PUT -H 'Content-type: application/json' -d '{"title": "My new title", "content": "My new content"}' localhost:3000/posts/1

Update an existing comment by id:

$ curl -X PUT -H 'Content-type: application/json' -d '{"name": "YuKitAs", "message": "My new message"}' localhost:3000/posts/2/comments/1

Delete an existing post by id:

$ curl -X DELETE localhost:3000/posts/1

All the comments of this post will be deleted as well.

Delete an existing comment by id:

$ curl -X DELETE localhost:3000/posts/2/comments/1
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].