Rails + Trailblazer API Boilerplate

A template of Rails + Trailblazer API only app. You can use this template as base template for any Rails + Trailblazer API only app.

Table of Contents

Setup

Versions

  • Ruby - 2.7.0
  • Ruby on Rails - 6.1.1
  • Trailblazer - 2.1.0

GemList

Recommended Gems

  • devise
  • jwt
  • versionist
  • active_model_serializers
  • redis-rails
  • apitome
  • bullet
  • brakeman
  • rubocop

Scaffolding

  • Controllers
app/controllers
├── application_controller.rb
├── concerns
├── v1
│   ├── base_controller.rb
│   └── users_controller.rb
└── v2
    └── users_controller.rb
  • Serializers
app/serializers/
├── v1
│   ├── expense_serializer.rb
│   └── user_serializer.rb
└── v2
    └── user_serializer.rb
  • Concepts
app/concepts/
├── api
│   └── macro.rb
└── v1
    └── user
        └── operation
            ├── index.rb
            └── login.rb

Documentation

  • Ganerate documentation

    $ rake docs:generate
  • Documentation route

    http://localhost:3000/api/docs

SampleCURL

curl --location --request GET 'localhost:3000/users' \
--header 'Accept: application/vnd.boilerplate-rails-trailblazer.com; version=1' \
--header 'X-Api-Key: eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2MTc5MzgxMjYsInVzZXJfaWQiOiIxIn0.Lc52z1w_9FvsIHTvrRx0ezhpl4BOljwRC0-A_thIIVM'