Rails API Base is a boilerplate project for JSON RESTful APIs. It follows the community best practices in terms of standards, security and maintainability, integrating a variety of testing and code quality tools. It's based on Rails 7.2 and Ruby 3.3.
Finally, it contains a plug an play Administration console (thanks to ActiveAdmin).
This template comes with:
.nvmrc
file.corepack enable
to install the required yarn binaries. Corepack is already included in newest node versions.bootstrap.sh
with the name of your project like ./bin/bootstrap.sh --name=my_awesome_project
.yarn install
and yarn build --watch
. This bundles the JS assets in the administration site using esbuild.bundle exec rspec
and make sure all tests pass (non-headless mode) or HEADLESS=true bundle exec rspec
(headless mode)bin/dev
.docker
and docker-compose
installed (You can check this by doing docker -v
and docker-compose -v
)bootstrap.sh
with the name of your project and the -d
or --for-docker
flag like ./bin/bootstrap.sh --name=my_awesome_project -d
./bin/bootstrap.sh --help
for the full details.docker-compose
network, remove the ports
key in the docker-compose.yml
from the db
service.bin/rspec .
.See Docker docs for more info
This template provides a handful of scripts to make your dev experience better!
bundle
commands.
bin/bundle install
rails
commands
bin/rails console
bash
commands
bin/web ls
bin/rspec .
bin/dev
You don't have to use these but they are designed to run the same when running with Docker or not.
To illustrate, bin/rails console
will run the console in the docker container when running with docker and locally when not.
config/initializers/rack_cors.rb
config/initializers/devise.rb
application.rb
See API documentation docs for more info
With bundle exec rails code:analysis
you can run the code analysis tool, you can omit rules with:
.rubocop.yml
config.reek
config/rails_best_practices.yml
brakeman -I
to generate config/brakeman.ignore
The rails_api_base
incorporates a user impersonation feature, allowing AdminUser
s to assume the identity of other User
s. This feature is disabled by default.
See Impersonation docs for more info
In order to use New Relic to monitor your application requests and metrics, you must setup NEW_RELIC_API_KEY
and NEW_RELIC_APP_NAME
environment variables.
To obtain an API key you must create an account in the platform.
Repo Settings
Test Coverage
tab, copy the Test Reporter ID
CC_TEST_REPORTER_ID
in the GitHub secrets and variablesYou can use CODEOWNERS file to define individuals or teams that are responsible for code in the repository.
Code owners are automatically requested for review when someone opens a pull request that modifies code that they own.
Rails API Base is maintained by Rootstrap with the help of our contributors.