Skip to content

Instantly share code, notes, and snippets.

@rx
Last active September 28, 2021 15:41
Show Gist options
  • Save rx/4802626a4badfc1a470811da4f4f9c27 to your computer and use it in GitHub Desktop.
Save rx/4802626a4badfc1a470811da4f4f9c27 to your computer and use it in GitHub Desktop.
Rails service - application template
ruby_version = '3.0.2'
file '.ruby-version', "ruby-#{ruby_version}\n"
gem 'redis'
gem 'sidekiq'
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem_group :development, :test do
gem 'dotenv-rails'
gem 'rubocop', require: false
gem 'rspec-rails', require: false
end
environment 'config.active_job.queue_adapter = :sidekiq'
environment "config.cache_store = :redis_cache_store, { url: ENV['REDIS_URL'] }"
file '.env', <<~CODE, force: true
export REDIS_URL=redis://localhost:6379/0
CODE
append_file '.gitignore' do <<~'CODE'
.idea
.env
CODE
end
gsub_file 'Gemfile', /^ruby\W'\d\.\d\.\d'$/, "ruby '#{ruby_version}'"
gsub_file 'config/application.rb', /^#\Wrequire\W\"active_job\/railtie\"$/, "require 'active_job/railtie'"
@stockandawe
Copy link

@rx, as we discussed, would love to make sure we have this set up with the following if possible:

  • NewRelic
  • A MaxwellLogger
  • Exception tracking with Raygun (since all our current apps are doing it)
  • A "status" API endpoint that displays the health of the API app when running (see how we currently do it for https://loss-live.himaxwell.com/)

@stockandawe
Copy link

@rx, another note - When I was working on this innovation sprint project, I had in the back of my mind to try and create a template for APIs at Maxwell to standarize that work. However, didn't have enough time to work on that - https://github.com/himaxwell/lox-api

But one of the things I wanted to do was decide on a gem or other seralizer so that we can follow the JSON API spec for any APIs we create a Maxwell. I ended up using the jsonapi-resources gem which I don't think we all like enough to make that the default for all APIs.

Another thing was the need to standardize the way we do API documentation. Even for non-external APIs, having a consistent way we can add documentation would be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment