thoughtbot / suspenders

A Rails template with our standard defaults.
https://thoughtbot.com
MIT License
4.01k stars 530 forks source link

Suspenders for API-only app? #943

Open mike-burns opened 5 years ago

mike-burns commented 5 years ago

Provide an answer to the question: should I use Suspenders if my app renders no HTML?

croaky commented 5 years ago

FWIW, I created a Rails app in API-only mode recently with:

rails new projectname -d postgresql --api --skip-turbolinks --skip-action-cable --skip-spring --skip-coffee --skip-bootsnap --skip-test --skip-active-storage

Made some edits, first commit looked something like this: https://gist.github.com/croaky/f11ff9e3be24ad317e6f175efcb07048

About two months later, Gemfile looks something like this:

# frozen_string_literal: true

source 'https://rubygems.org'

ruby '2.5.1'

gem 'clearance', '~> 1.16.1'
gem 'lograge', '~> 0.10'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 3.11'
gem 'rails', '~> 5.2.1'

group :development, :test do
  gem 'byebug'
  gem 'dotenv-rails', '~> 2.5.0'
  gem 'factory_bot'
  gem 'rspec-rails'
  gem 'shoulda-matchers', '~> 3.1'
  gem 'webmock'
end

group :development do
  gem 'letter_opener', '~> 1.6.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
end

config/initializers/clearance.rb something like this:

# frozen_string_literal: true

Clearance.configure do |config|
  config.allow_sign_up = false
  config.httponly = true
  config.mailer_sender = 'example@example.com'
  config.rotate_csrf_on_sign_in = true
  config.routes = false
  config.secure_cookie = true
end
mike-burns commented 5 years ago

Thank you for this, @croaky ! I especially love knowing what the Gemfile looks like after two months of use.

stevepolitodesign commented 4 months ago

In #1135 we introduced suspenders:install:web to allow for the possibility of suspenders:install:api. That pull request also introduced guards to ensure suspenders:install:web cannot be run on an API-only application.