Skip to content

Commit aafe39b

Browse files
author
Chang-Woo Rhee
committed
Init
0 parents  commit aafe39b

File tree

87 files changed

+1723
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1723
-0
lines changed

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
2+
#
3+
# If you find yourself ignoring temporary files generated by your text editor
4+
# or operating system, you probably want to add a global ignore instead:
5+
# git config --global core.excludesfile '~/.gitignore_global'
6+
7+
# Ignore bundler config.
8+
/.bundle
9+
10+
# Ignore all logfiles and tempfiles.
11+
/log/*
12+
/tmp/*
13+
!/log/.keep
14+
!/tmp/.keep
15+
16+
# Ignore uploaded files in development.
17+
/storage/*
18+
!/storage/.keep
19+
.byebug_history
20+
21+
# Ignore master key for decrypting credentials and more.
22+
/config/master.key

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.6.0

Gemfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
source 'https://rubygems.org'
2+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3+
4+
ruby '2.6.0'
5+
6+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
7+
gem 'rails', '~> 6.0.2', '>= 6.0.2.1'
8+
# Use postgresql as the database for Active Record
9+
gem 'pg', '>= 0.18', '< 2.0'
10+
# Use Puma as the app server
11+
gem 'puma', '~> 4.1'
12+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
13+
# gem 'jbuilder', '~> 2.7'
14+
# Use Redis adapter to run Action Cable in production
15+
# gem 'redis', '~> 4.0'
16+
# Use Active Model has_secure_password
17+
# gem 'bcrypt', '~> 3.1.7'
18+
19+
# Use Active Storage variant
20+
# gem 'image_processing', '~> 1.2'
21+
22+
# Reduces boot times through caching; required in config/boot.rb
23+
gem 'bootsnap', '>= 1.4.2', require: false
24+
25+
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
26+
# gem 'rack-cors'
27+
28+
group :development, :test do
29+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
30+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
31+
end
32+
33+
group :development do
34+
gem 'listen', '>= 3.0.5', '< 3.2'
35+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
36+
gem 'spring'
37+
gem 'spring-watcher-listen', '~> 2.0.0'
38+
end
39+
40+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
41+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
42+
gem 'jwt-rails', '~> 0.0.1'
43+
gem 'docker-postgres-rails', '~> 0.0.1'
44+
45+
46+
gem 'jwt'
47+
gem 'bcrypt', '~> 3.1.7'
48+
gem 'active_model_serializers'
49+
gem 'faker', '~> 1.9.1', group: [:development, :test]
50+
51+
# Gemfile
52+
gem 'rswag-api'
53+
gem 'rswag-ui'
54+
55+
group :development, :test do
56+
gem 'rspec-rails'
57+
gem 'rswag-specs'
58+
end
59+

Gemfile.lock

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
actioncable (6.0.2.1)
5+
actionpack (= 6.0.2.1)
6+
nio4r (~> 2.0)
7+
websocket-driver (>= 0.6.1)
8+
actionmailbox (6.0.2.1)
9+
actionpack (= 6.0.2.1)
10+
activejob (= 6.0.2.1)
11+
activerecord (= 6.0.2.1)
12+
activestorage (= 6.0.2.1)
13+
activesupport (= 6.0.2.1)
14+
mail (>= 2.7.1)
15+
actionmailer (6.0.2.1)
16+
actionpack (= 6.0.2.1)
17+
actionview (= 6.0.2.1)
18+
activejob (= 6.0.2.1)
19+
mail (~> 2.5, >= 2.5.4)
20+
rails-dom-testing (~> 2.0)
21+
actionpack (6.0.2.1)
22+
actionview (= 6.0.2.1)
23+
activesupport (= 6.0.2.1)
24+
rack (~> 2.0, >= 2.0.8)
25+
rack-test (>= 0.6.3)
26+
rails-dom-testing (~> 2.0)
27+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
28+
actiontext (6.0.2.1)
29+
actionpack (= 6.0.2.1)
30+
activerecord (= 6.0.2.1)
31+
activestorage (= 6.0.2.1)
32+
activesupport (= 6.0.2.1)
33+
nokogiri (>= 1.8.5)
34+
actionview (6.0.2.1)
35+
activesupport (= 6.0.2.1)
36+
builder (~> 3.1)
37+
erubi (~> 1.4)
38+
rails-dom-testing (~> 2.0)
39+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
40+
active_model_serializers (0.10.10)
41+
actionpack (>= 4.1, < 6.1)
42+
activemodel (>= 4.1, < 6.1)
43+
case_transform (>= 0.2)
44+
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
45+
activejob (6.0.2.1)
46+
activesupport (= 6.0.2.1)
47+
globalid (>= 0.3.6)
48+
activemodel (6.0.2.1)
49+
activesupport (= 6.0.2.1)
50+
activerecord (6.0.2.1)
51+
activemodel (= 6.0.2.1)
52+
activesupport (= 6.0.2.1)
53+
activestorage (6.0.2.1)
54+
actionpack (= 6.0.2.1)
55+
activejob (= 6.0.2.1)
56+
activerecord (= 6.0.2.1)
57+
marcel (~> 0.3.1)
58+
activesupport (6.0.2.1)
59+
concurrent-ruby (~> 1.0, >= 1.0.2)
60+
i18n (>= 0.7, < 2)
61+
minitest (~> 5.1)
62+
tzinfo (~> 1.1)
63+
zeitwerk (~> 2.2)
64+
addressable (2.7.0)
65+
public_suffix (>= 2.0.2, < 5.0)
66+
bcrypt (3.1.13)
67+
bootsnap (1.4.5)
68+
msgpack (~> 1.0)
69+
builder (3.2.4)
70+
byebug (11.0.1)
71+
case_transform (0.2)
72+
activesupport
73+
concurrent-ruby (1.1.5)
74+
crass (1.0.5)
75+
diff-lcs (1.3)
76+
docker-postgres-rails (0.0.1)
77+
erubi (1.9.0)
78+
faker (1.9.6)
79+
i18n (>= 0.7)
80+
ffi (1.11.3)
81+
globalid (0.4.2)
82+
activesupport (>= 4.2.0)
83+
i18n (1.7.0)
84+
concurrent-ruby (~> 1.0)
85+
json-schema (2.8.1)
86+
addressable (>= 2.4)
87+
jsonapi-renderer (0.2.2)
88+
jwt (2.2.1)
89+
jwt-rails (0.0.1)
90+
listen (3.1.5)
91+
rb-fsevent (~> 0.9, >= 0.9.4)
92+
rb-inotify (~> 0.9, >= 0.9.7)
93+
ruby_dep (~> 1.2)
94+
loofah (2.4.0)
95+
crass (~> 1.0.2)
96+
nokogiri (>= 1.5.9)
97+
mail (2.7.1)
98+
mini_mime (>= 0.1.1)
99+
marcel (0.3.3)
100+
mimemagic (~> 0.3.2)
101+
method_source (0.9.2)
102+
mimemagic (0.3.3)
103+
mini_mime (1.0.2)
104+
mini_portile2 (2.4.0)
105+
minitest (5.13.0)
106+
msgpack (1.3.1)
107+
nio4r (2.5.2)
108+
nokogiri (1.10.7)
109+
mini_portile2 (~> 2.4.0)
110+
pg (1.2.0)
111+
public_suffix (4.0.2)
112+
puma (4.3.1)
113+
nio4r (~> 2.0)
114+
rack (2.0.8)
115+
rack-test (1.1.0)
116+
rack (>= 1.0, < 3)
117+
rails (6.0.2.1)
118+
actioncable (= 6.0.2.1)
119+
actionmailbox (= 6.0.2.1)
120+
actionmailer (= 6.0.2.1)
121+
actionpack (= 6.0.2.1)
122+
actiontext (= 6.0.2.1)
123+
actionview (= 6.0.2.1)
124+
activejob (= 6.0.2.1)
125+
activemodel (= 6.0.2.1)
126+
activerecord (= 6.0.2.1)
127+
activestorage (= 6.0.2.1)
128+
activesupport (= 6.0.2.1)
129+
bundler (>= 1.3.0)
130+
railties (= 6.0.2.1)
131+
sprockets-rails (>= 2.0.0)
132+
rails-dom-testing (2.0.3)
133+
activesupport (>= 4.2.0)
134+
nokogiri (>= 1.6)
135+
rails-html-sanitizer (1.3.0)
136+
loofah (~> 2.3)
137+
railties (6.0.2.1)
138+
actionpack (= 6.0.2.1)
139+
activesupport (= 6.0.2.1)
140+
method_source
141+
rake (>= 0.8.7)
142+
thor (>= 0.20.3, < 2.0)
143+
rake (13.0.1)
144+
rb-fsevent (0.10.3)
145+
rb-inotify (0.10.1)
146+
ffi (~> 1.0)
147+
rspec-core (3.9.0)
148+
rspec-support (~> 3.9.0)
149+
rspec-expectations (3.9.0)
150+
diff-lcs (>= 1.2.0, < 2.0)
151+
rspec-support (~> 3.9.0)
152+
rspec-mocks (3.9.0)
153+
diff-lcs (>= 1.2.0, < 2.0)
154+
rspec-support (~> 3.9.0)
155+
rspec-rails (3.9.0)
156+
actionpack (>= 3.0)
157+
activesupport (>= 3.0)
158+
railties (>= 3.0)
159+
rspec-core (~> 3.9.0)
160+
rspec-expectations (~> 3.9.0)
161+
rspec-mocks (~> 3.9.0)
162+
rspec-support (~> 3.9.0)
163+
rspec-support (3.9.0)
164+
rswag-api (2.2.0)
165+
railties (>= 3.1, < 6.1)
166+
rswag-specs (2.2.0)
167+
activesupport (>= 3.1, < 6.1)
168+
json-schema (~> 2.2)
169+
railties (>= 3.1, < 6.1)
170+
rswag-ui (2.2.0)
171+
actionpack (>= 3.1, < 6.1)
172+
railties (>= 3.1, < 6.1)
173+
ruby_dep (1.5.0)
174+
spring (2.1.0)
175+
spring-watcher-listen (2.0.1)
176+
listen (>= 2.7, < 4.0)
177+
spring (>= 1.2, < 3.0)
178+
sprockets (4.0.0)
179+
concurrent-ruby (~> 1.0)
180+
rack (> 1, < 3)
181+
sprockets-rails (3.2.1)
182+
actionpack (>= 4.0)
183+
activesupport (>= 4.0)
184+
sprockets (>= 3.0.0)
185+
thor (1.0.1)
186+
thread_safe (0.3.6)
187+
tzinfo (1.2.6)
188+
thread_safe (~> 0.1)
189+
websocket-driver (0.7.1)
190+
websocket-extensions (>= 0.1.0)
191+
websocket-extensions (0.1.4)
192+
zeitwerk (2.2.2)
193+
194+
PLATFORMS
195+
ruby
196+
197+
DEPENDENCIES
198+
active_model_serializers
199+
bcrypt (~> 3.1.7)
200+
bootsnap (>= 1.4.2)
201+
byebug
202+
docker-postgres-rails (~> 0.0.1)
203+
faker (~> 1.9.1)
204+
jwt
205+
jwt-rails (~> 0.0.1)
206+
listen (>= 3.0.5, < 3.2)
207+
pg (>= 0.18, < 2.0)
208+
puma (~> 4.1)
209+
rails (~> 6.0.2, >= 6.0.2.1)
210+
rspec-rails
211+
rswag-api
212+
rswag-specs
213+
rswag-ui
214+
spring
215+
spring-watcher-listen (~> 2.0.0)
216+
tzinfo-data
217+
218+
RUBY VERSION
219+
ruby 2.6.0p0
220+
221+
BUNDLED WITH
222+
2.1.0

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# README
2+
3+
This README would normally document whatever steps are necessary to get the
4+
application up and running.
5+
6+
Things you may want to cover:
7+
8+
* Ruby version
9+
10+
* System dependencies
11+
12+
* Configuration
13+
14+
* Database creation
15+
16+
* Database initialization
17+
18+
* How to run the test suite
19+
20+
* Services (job queues, cache servers, search engines, etc.)
21+
22+
* Deployment instructions
23+
24+
* ...

Rakefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Add your own tasks in files placed in lib/tasks ending in .rake,
2+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3+
4+
require_relative 'config/application'
5+
6+
Rails.application.load_tasks
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ApplicationCable
2+
class Channel < ActionCable::Channel::Base
3+
end
4+
end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module ApplicationCable
2+
class Connection < ActionCable::Connection::Base
3+
end
4+
end
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
require 'json_web_token'
2+
3+
class ApplicationController < ActionController::API
4+
5+
def not_found
6+
render json: { error: 'not_found' }
7+
end
8+
9+
def authorize_request
10+
header = request.headers['Authorization']
11+
header = header.split(' ').last if header
12+
begin
13+
@decoded = JsonWebToken.decode(header)
14+
@current_user = User.find(@decoded[:user_id])
15+
rescue ActiveRecord::RecordNotFound => e
16+
render json: { errors: e.message }, status: :unauthorized
17+
rescue JWT::DecodeError => e
18+
render json: { errors: e.message }, status: :unauthorized
19+
end
20+
end
21+
22+
def is_owner user_id
23+
unless user_id == current_user.id
24+
render json: nil, status: :forbidden
25+
return
26+
end
27+
end
28+
29+
def is_owner_object data
30+
if data.nil? or data.user_id.nil?
31+
return render status: :not_found
32+
else
33+
is_owner data.user_id
34+
end
35+
end
36+
37+
end

0 commit comments

Comments
 (0)