This is an opinionated Sinatra application with conventions similar to Rails. What includes:
bin folder there are scripts that let you:
- Start a cosole:
- Start the webapp:
- Start workers:
Also the repo contains a Makefile with all you need.
The app is configured to use Postgres by default, you can check and change the configuration in the
If you don't want to use a database, you can remove the related dependencies (
pagy) and its usages.
The connection pool is configured in the
activerecord initializer and uses an environment variable named
Sinatra activerecord provides
rake commands to perform database actions like Rails does.
For example, to create a new migration you can run:
bundle exec rake db:create_migration NAME=migration_name
This app uses puma as the webserver which you can configure with environment variables:
This app uses the rack-cors gem to provide cross domain access. You can configure this further in the
All your business logic and domain classes are intended to live in the
lib folder. In this base application you have a
User model example and not much more.
All your classes are loaded using the
require_all gem inside the
lib/boot.rb file. You can require any other dependency you need in that file.
One thing that I like is to use environment variables for secrets (they are defined in
config/secrets.yml like Rails) and raise an exception if there is one missing (how many times have you deployed an application and forgot to set an env variable?). For this I created a class called
Application which handles all of that and has some other configuration like the logger.
You can use your secrets like:
The Sidekiq configuration is pretty much the default in this repo. The config files are located in
The Sidekiq's web UI is loaded in
/sidekiq using basic authentication. You can change this in the
config.ru file. The environment variables to set user and password are
Docker configuration is provided and you can run the entire application using: