Skip to content
This repository has been archived by the owner on Mar 2, 2020. It is now read-only.

Commit

Permalink
Up: difference between API and App
Browse files Browse the repository at this point in the history
  • Loading branch information
seawolf committed Feb 25, 2020
1 parent 4d52ac3 commit 2665ded
Show file tree
Hide file tree
Showing 35 changed files with 449 additions and 42 deletions.
4 changes: 4 additions & 0 deletions API-to-App/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
/storage/*
!/storage/.keep

/node_modules
/yarn-error.log

/public/assets
.byebug_history

# Ignore master key for decrypting credentials and more.
Expand Down
25 changes: 21 additions & 4 deletions API-to-App/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,19 @@ gem 'rails', '~> 5.2.4', '>= 5.2.4.1'
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.5'
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
Expand All @@ -25,21 +36,27 @@ gem 'puma', '~> 3.11'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', 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
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 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

group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'chromedriver-helper'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
67 changes: 67 additions & 0 deletions API-to-App/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,47 @@ GEM
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
archive-zip (0.12.0)
io-like (~> 0.3.0)
arel (9.0.0)
bindex (0.8.1)
bootsnap (1.4.6)
msgpack (~> 1.0)
builder (3.2.4)
byebug (11.0.1)
capybara (3.15.1)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (~> 1.2)
xpath (~> 3.2)
childprocess (3.0.0)
chromedriver-helper (2.1.1)
archive-zip (~> 0.10)
nokogiri (~> 1.8)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.6)
crass (1.0.6)
erubi (1.9.0)
execjs (2.7.0)
ffi (1.12.2)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
io-like (0.3.1)
jbuilder (2.10.0)
activesupport (>= 5.0.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
Expand All @@ -75,6 +103,7 @@ GEM
nio4r (2.5.2)
nokogiri (1.10.8)
mini_portile2 (~> 2.4.0)
public_suffix (4.0.3)
puma (3.12.2)
rack (2.2.2)
rack-test (1.1.0)
Expand Down Expand Up @@ -107,7 +136,23 @@ GEM
rb-fsevent (0.10.3)
rb-inotify (0.10.1)
ffi (~> 1.0)
regexp_parser (1.7.0)
ruby_dep (1.5.0)
rubyzip (1.3.0)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
selenium-webdriver (3.142.7)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
spring (2.0.2)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1)
Expand All @@ -123,25 +168,47 @@ GEM
sqlite3 (1.4.2)
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.10)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (1.2.6)
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
web-console (3.7.0)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
xpath (3.2.0)
nokogiri (~> 1.8)

PLATFORMS
ruby

DEPENDENCIES
bootsnap (>= 1.1.0)
byebug
capybara (>= 2.15)
chromedriver-helper
coffee-rails (~> 4.2)
jbuilder (~> 2.5)
listen (>= 3.0.5, < 3.2)
puma (~> 3.11)
rails (~> 5.2.4, >= 5.2.4.1)
sass-rails (~> 5.0)
selenium-webdriver
spring
spring-watcher-listen (~> 2.0.0)
sqlite3
turbolinks (~> 5)
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)

RUBY VERSION
ruby 2.3.3p222
Expand Down
3 changes: 3 additions & 0 deletions API-to-App/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
Empty file.
16 changes: 16 additions & 0 deletions API-to-App/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require rails-ujs
//= require activestorage
//= require turbolinks
//= require_tree .
13 changes: 13 additions & 0 deletions API-to-App/app/assets/javascripts/cable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Action Cable provides the framework to deal with WebSockets in Rails.
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
//
//= require action_cable
//= require_self
//= require_tree ./channels

(function() {
this.App || (this.App = {});

App.cable = ActionCable.createConsumer();

}).call(this);
Empty file.
15 changes: 15 additions & 0 deletions API-to-App/app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require_self
*/
2 changes: 1 addition & 1 deletion API-to-App/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
class ApplicationController < ActionController::API
class ApplicationController < ActionController::Base
end
2 changes: 2 additions & 0 deletions API-to-App/app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ApplicationHelper
end
15 changes: 15 additions & 0 deletions API-to-App/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Application</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>

<body>
<%= yield %>
</body>
</html>
3 changes: 3 additions & 0 deletions API-to-App/bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ chdir APP_ROOT do
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')

# Install JavaScript dependencies if using Yarn
# system('bin/yarn')

# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
Expand Down
3 changes: 3 additions & 0 deletions API-to-App/bin/update
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ chdir APP_ROOT do
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')

# Install JavaScript dependencies if using Yarn
# system('bin/yarn')

puts "\n== Updating database =="
system! 'bin/rails db:migrate'

Expand Down
11 changes: 11 additions & 0 deletions API-to-App/bin/yarn
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env ruby
APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
begin
exec "yarnpkg", *ARGV
rescue Errno::ENOENT
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1
end
end
20 changes: 2 additions & 18 deletions API-to-App/config/application.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
require_relative 'boot'

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "action_cable/engine"
# require "sprockets/railtie"
require "rails/test_unit/railtie"
require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

module API
module Application
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
Expand All @@ -26,10 +15,5 @@ class Application < Rails::Application
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.

# Only loads a smaller set of middleware suitable for API only apps.
# Middleware like session, flash, cookies can be added back manually.
# Skip views, helpers and assets when generating a new resource.
config.api_only = true
end
end
2 changes: 1 addition & 1 deletion API-to-App/config/cable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ test:
production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: API_production
channel_prefix: Application_production
2 changes: 1 addition & 1 deletion API-to-App/config/credentials.yml.enc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
oiqcKoSWwAultmWX9PMZNOIZvPX5J/wRArggHmR/28zudNmJg4hA47wvzy4d6R94u17N11OJLRdUPEeS54p7TRsT5ZHGPP+3rr2ssTPb0El5iKF/ZP6G8ItnQxmWW6iQctNzKwGicmGp+9glVsuzuozh++YCUB2jD5+QqMYCDw1TH7qOw+cO4l4aOLCbEADHvW0qRANTXQdcmETr0cnV3D1uKez0lsY/vE9gFvnFqpT3t/m4ffMBViSsaBAyHBVA9C9fXDovlv2AxDbwFjxvOLb5UFetcUjkVDh5nyAMDU8p5yhBKKKTDW5/wpSI3sVihDv9IUtKflJOfzgUTmdOihkoff6htZ+PP9bY1bV6ZbGZz7SzpxnY3WbWKimMHUZDYxwSMN1l2S3qgnLMCk3ieLchCdvCHjpt+buo--PRcTzZLNGrlz3+8R--nHoK31p9d98xJ6nx5srtug==
+/6LeufE6ykHvTGcy8Jayi+OYqGIec3PLXqP5HakWLLGbyjlCAVx6ygGPkBp6HqsPhRxFWZHbsG5cPoIXOjqdyfvIrXR6pXSLMifmGD6Z+MpfZ8yi15OarLaO6ppBRyWYZrV1X8gyP7WhzCammNxDCPrkuLxB9BdCp6Y8kjv4FUNW3EAAq5yZhy1bKadQWwtnxUKep0I3deCDKk04hkwC56CvX5bhTG4Zn3PT9VFrbq4ZA5oV7Gc6z0slXRHYw9O6QFBjk+2Iocz0Pbxi2T4A3XHhFx+Wlnh0wXkRQ3QGMrfKKrkGfZTZLTczDXJ+q3HVGmr6ZYgwkRwXhq++C+DVXqvrcl5sAfE9CqJnztDXWLR7fT5uP/MnIhFpvnF7jlWrpwrxSI+kJjKUKfDQWGbI4ErqpxAMWZa2Z9X--Gh8Fxx595F3mQZzQ--Ls1YZD+sUmik2uRAHBIluQ==
7 changes: 7 additions & 0 deletions API-to-App/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true

# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true

# Suppress logger output for asset requests.
config.assets.quiet = true

# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
Expand Down
11 changes: 10 additions & 1 deletion API-to-App/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?

# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false

# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb

# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'

Expand Down Expand Up @@ -52,7 +61,7 @@

# Use a real queuing backend for Active Job (and separate queues per environment)
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "API_#{Rails.env}"
# config.active_job.queue_name_prefix = "Application_#{Rails.env}"

config.action_mailer.perform_caching = false

Expand Down
14 changes: 14 additions & 0 deletions API-to-App/config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'

# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.
Rails.application.config.assets.paths << Rails.root.join('node_modules')

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in the app/assets
# folder are already added.
# Rails.application.config.assets.precompile += %w( admin.js admin.css )
Loading

0 comments on commit 2665ded

Please sign in to comment.