Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6d7b45a
Implement the REST API for BookStore
macnick Aug 7, 2020
9d600ca
Implement the REST API for BookStore
macnick Aug 7, 2020
2336799
Merge branch 'milestone-6' of https://github.com/macnick/react-bookst…
macnick Aug 7, 2020
65e9118
Merge branch 'milestone-6' of https://github.com/macnick/react-bookst…
macnick Aug 7, 2020
8ecd580
Merge branch 'milestone-6' of https://github.com/macnick/react-bookst…
macnick Aug 7, 2020
73798d7
Merge branch 'milestone-6' of https://github.com/macnick/react-bookst…
macnick Aug 7, 2020
9fa3e82
Merge branch 'milestone-6' of https://github.com/macnick/react-bookst…
macnick Aug 7, 2020
bc212e9
add AppRouter and author in the components
Abdusaid10 Aug 7, 2020
4302a95
Commit changes
macnick Aug 7, 2020
b9f8006
Fix conflict
macnick Aug 7, 2020
355a177
Fix conflict
macnick Aug 7, 2020
ecfe379
Merge branch 'milestone-6' of https://github.com/macnick/react-bookst…
Abdusaid10 Aug 10, 2020
c8f1750
implement api-services module and add create in the form to store in …
Abdusaid10 Aug 10, 2020
a46cc40
implement api-services module and add create in the form to store in …
Abdusaid10 Aug 10, 2020
66fb426
Merge branch 'milestone-6' of https://github.com/macnick/react-bookst…
Abdusaid10 Aug 10, 2020
4057c89
Test services
macnick Aug 10, 2020
534a402
Merge branch 'milestone-6' of https://github.com/macnick/react-bookst…
Abdusaid10 Aug 11, 2020
0a4d50e
playing with the api
Abdusaid10 Aug 11, 2020
77ffe94
install redux-logger
macnick Aug 12, 2020
09a52cb
install redux devtools
macnick Aug 12, 2020
dbba62c
We have a store
macnick Aug 12, 2020
ea717fd
MapStateToProps properly
macnick Aug 12, 2020
4e5c2bf
Make filter work again
macnick Aug 12, 2020
3c673a9
Refresh list fix
macnick Aug 13, 2020
f9ece18
implement remove async
Abdusaid10 Aug 13, 2020
7ab7f84
fix create. Make it async
Abdusaid10 Aug 13, 2020
d2d3537
Merge
macnick Aug 13, 2020
e44a8b0
remove unnecessary code
Abdusaid10 Aug 13, 2020
02eb003
Merge branch 'api-get-req' of https://github.com/macnick/react-bookst…
macnick Aug 13, 2020
6dd5539
Style changes
macnick Aug 13, 2020
c2a289e
linter error fix
Abdusaid10 Aug 13, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,24 @@ dist
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config.
bookstore-api/.bundle
# Ignore all logfiles and tempfiles.
bookstore-api/log/*
bookstore-api/tmp/*
bookstore-api/log/.keep
bookstore-api/tmp/.keep
# Ignore pidfiles, but keep the directory.
bookstore-api/tmp/pids/*
bookstore-api/tmp/pids/
bookstore-api/tmp/pids/.keep
# Ignore uploaded files in development.
bookstore-api/storage/*
bookstore-api/storage/.keep
bookstore-api/.byebug_history
# Ignore master key for decrypting credentials and more.
bookstore-api/config/master.key
1 change: 1 addition & 0 deletions bookstore-apii/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.6.5
41 changes: 41 additions & 0 deletions bookstore-apii/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.5'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.2'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
gem 'rack-cors'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
gem 'listen', '~> 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
167 changes: 167 additions & 0 deletions bookstore-apii/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.3.2)
actionpack (= 6.0.3.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.3.2)
actionpack (= 6.0.3.2)
activejob (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
mail (>= 2.7.1)
actionmailer (6.0.3.2)
actionpack (= 6.0.3.2)
actionview (= 6.0.3.2)
activejob (= 6.0.3.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.3.2)
actionview (= 6.0.3.2)
activesupport (= 6.0.3.2)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.3.2)
actionpack (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
nokogiri (>= 1.8.5)
actionview (6.0.3.2)
activesupport (= 6.0.3.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.3.2)
activesupport (= 6.0.3.2)
globalid (>= 0.3.6)
activemodel (6.0.3.2)
activesupport (= 6.0.3.2)
activerecord (6.0.3.2)
activemodel (= 6.0.3.2)
activesupport (= 6.0.3.2)
activestorage (6.0.3.2)
actionpack (= 6.0.3.2)
activejob (= 6.0.3.2)
activerecord (= 6.0.3.2)
marcel (~> 0.3.1)
activesupport (6.0.3.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
bootsnap (1.4.7)
msgpack (~> 1.0)
builder (3.2.4)
byebug (11.1.3)
concurrent-ruby (1.1.6)
crass (1.0.6)
erubi (1.9.0)
ffi (1.13.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
listen (3.2.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.6.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (1.0.0)
mimemagic (0.3.5)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.1)
msgpack (1.3.3)
nio4r (2.5.2)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
pg (1.2.3)
puma (4.3.5)
nio4r (~> 2.0)
rack (2.2.3)
rack-cors (1.1.1)
rack (>= 2.0.0)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.3.2)
actioncable (= 6.0.3.2)
actionmailbox (= 6.0.3.2)
actionmailer (= 6.0.3.2)
actionpack (= 6.0.3.2)
actiontext (= 6.0.3.2)
actionview (= 6.0.3.2)
activejob (= 6.0.3.2)
activemodel (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
bundler (>= 1.3.0)
railties (= 6.0.3.2)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.0.3.2)
actionpack (= 6.0.3.2)
activesupport (= 6.0.3.2)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rake (13.0.1)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
spring (2.1.0)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
websocket-driver (0.7.3)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.4.0)

PLATFORMS
ruby

DEPENDENCIES
bootsnap (>= 1.4.2)
byebug
listen (~> 3.2)
pg (>= 0.18, < 2.0)
puma (~> 4.1)
rack-cors
rails (~> 6.0.3, >= 6.0.3.2)
spring
spring-watcher-listen (~> 2.0.0)
tzinfo-data

RUBY VERSION
ruby 2.6.5p114

BUNDLED WITH
2.1.4
24 changes: 24 additions & 0 deletions bookstore-apii/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# README

This README would normally document whatever steps are necessary to get the
application up and running.

Things you may want to cover:

* Ruby version

* System dependencies

* Configuration

* Database creation

* Database initialization

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...
6 changes: 6 additions & 0 deletions bookstore-apii/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative 'config/application'

Rails.application.load_tasks
4 changes: 4 additions & 0 deletions bookstore-apii/app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
4 changes: 4 additions & 0 deletions bookstore-apii/app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
end
end
3 changes: 3 additions & 0 deletions bookstore-apii/app/controllers/api/v1/api_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Api::V1::ApiController < ActionController::API

end
38 changes: 38 additions & 0 deletions bookstore-apii/app/controllers/api/v1/books_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
class Api::V1::BooksController < Api::V1::ApiController
before_action :set_book, only: [:update, :destroy]

def index
render json: Book.all
end

def create
@book = Book.new(book_params)
if @book.save
render json: @book, status: :created
else
render json: @book.errors, status: :unprocessable_entity
end
end

def update
if @book.update(book_params)
render json: @book
else
render json: @book.erros, status: :unprocessable_entity
end
end

def destroy
@book.destroy
end

private
def set_book
@book = Book.find(params[:id])
end

def book_params
params.require(:book).permit(:title, :author, :category)
end

end
2 changes: 2 additions & 0 deletions bookstore-apii/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ApplicationController < ActionController::API
end
Empty file.
7 changes: 7 additions & 0 deletions bookstore-apii/app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked

# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError
end
4 changes: 4 additions & 0 deletions bookstore-apii/app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
end
3 changes: 3 additions & 0 deletions bookstore-apii/app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
2 changes: 2 additions & 0 deletions bookstore-apii/app/models/book.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Book < ApplicationRecord
end
Empty file.
13 changes: 13 additions & 0 deletions bookstore-apii/app/views/layouts/mailer.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
/* Email styles need to be inline */
</style>
</head>

<body>
<%= yield %>
</body>
</html>
1 change: 1 addition & 0 deletions bookstore-apii/app/views/layouts/mailer.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= yield %>
4 changes: 4 additions & 0 deletions bookstore-apii/bin/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
4 changes: 4 additions & 0 deletions bookstore-apii/bin/rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
Rake.application.run
Loading