From d220342813d47a71e0971fd66b95787687d1e70e Mon Sep 17 00:00:00 2001 From: Denis Zakharov <78980031+DenisZackharov@users.noreply.github.com> Date: Thu, 15 Feb 2024 13:29:01 +0300 Subject: [PATCH] Heroku setup (#192) * add procfile * add cors * add scss link direcotry * change manifest * change manifest 2 * change manifest 3 * change manifest 4 * change manifest 5 * fix rspec support --- .nvmrc | 1 + Gemfile | 1 + Gemfile.lock | 3 +++ Procfile | 1 + app/assets/config/manifest.js | 7 ++++++- config/initializers/cors.rb | 11 +++++++++++ package.json | 3 +++ {app/spec => spec}/support/factory_bot.rb | 0 yarn.lock | 7 +------ 9 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 .nvmrc create mode 100644 Procfile create mode 100644 config/initializers/cors.rb rename {app/spec => spec}/support/factory_bot.rb (100%) diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..f274881e --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v16.16.0 diff --git a/Gemfile b/Gemfile index 2f7e2042..2428ccf5 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,7 @@ gem "active_model_serializers" gem "enumerize" gem "graphql" gem "interactor", "~> 3.0" +gem "rack-cors" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" gem "rails", "~> 6.1.7" # Use postgresql as the database for Active Record diff --git a/Gemfile.lock b/Gemfile.lock index 49f6a7e6..1a7357a8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -190,6 +190,8 @@ GEM nio4r (~> 2.0) racc (1.7.1) rack (2.2.8) + rack-cors (2.0.1) + rack (>= 2.0.0) rack-mini-profiler (2.3.4) rack (>= 1.2.0) rack-proxy (0.7.7) @@ -385,6 +387,7 @@ DEPENDENCIES pg (~> 1.1) pry puma (~> 5.0) + rack-cors rack-mini-profiler (~> 2.0) rails (~> 6.1.7) rspec-rails (~> 6.0.0) diff --git a/Procfile b/Procfile new file mode 100644 index 00000000..c2c566e8 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: bundle exec puma -C config/puma.rb diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index 59181933..aaf46818 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -1,2 +1,7 @@ //= link_tree ../images -//= link_directory ../stylesheets .css +//= link _variables.scss +//= link application.scss +//= link base.scss +//= link form.scss +//= link header.scss +//= link reset.scss diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb new file mode 100644 index 00000000..6ba98518 --- /dev/null +++ b/config/initializers/cors.rb @@ -0,0 +1,11 @@ +if ENV["CORS_ORIGINS"].present? + Rails.application.config.middleware.insert_before 0, Rack::Cors do + allow do + origins(*ENV.fetch("CORS_ORIGINS", "").split(",")) + + resource "*", + headers: :any, + methods: %i[get post put patch delete options head] + end + end +end diff --git a/package.json b/package.json index ac00dd72..2351f6b6 100644 --- a/package.json +++ b/package.json @@ -16,5 +16,8 @@ "version": "0.1.0", "devDependencies": { "webpack-dev-server": "^3" + }, + "engines": { + "node": "16.16.0" } } diff --git a/app/spec/support/factory_bot.rb b/spec/support/factory_bot.rb similarity index 100% rename from app/spec/support/factory_bot.rb rename to spec/support/factory_bot.rb diff --git a/yarn.lock b/yarn.lock index 3fdfb222..19d09304 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4236,16 +4236,11 @@ lodash.uniq@^4.5.0: resolved "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ== -lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.5: +lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.21, lodash@^4.17.5: version "4.17.21" resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== -lodash@^4.17.21: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - loglevel@^1.6.8: version "1.8.1" resolved "https://registry.npmjs.org/loglevel/-/loglevel-1.8.1.tgz#5c621f83d5b48c54ae93b6156353f555963377b4"