Skip to content
/ rails-api-rest Public template

Rails 7 REST (openapi) template repo with Dockerfile, docker-compose and docker-swarm stack

Notifications You must be signed in to change notification settings

kodius/rails-api-rest

Repository files navigation

rails-api-rest 📦

What is this? ❓

This is a core rails API starter project accompanied with examples of a couple of concepts we like to use in our Rails projects. It's meant to be used as a template (meaning when you start a new repository on Github, you select this repository as the "template" to use). With it you get a barebones rails api setup (initialized with the --api flag during generation), using postgres for DB and a couple of gems we like to use plus samples of Services, Queries, Validators, OpenAPI definitions and such, to make it easier when starting a new project from scratch instead of having to think what to do.

MVC

The project is meant as a backend-only rails API, and as such the "view" in MVC in this case means having JSON responses, not actual templates. Or rather, any front-end framework handling the viewing whichever way you like.

The other parts of MVC, the Model and Controller -- they're both meant to be skinny., which is why we're making extensive use of Actions and Validators, to make them clean and make them contain as little as possible.

Actions 👨‍🔧

What are Actions and how to use them

Authorization

Authorization is imeplemented using Devise and set to act like a typical API with JWT based auth.

Serializers

Implemented with blueprinter. Click the link for more info.

OpenAPI 🌐

What is OpenAPI and how to use it

We're using rswag. The explorer sits over at /spec.

Coding Standards 👔

We like Ruby for its elegance and almost natural-like syntax and expresiveness. https://github.com/rubocop/rails-style-guide

Recommended extensions

https://marketplace.visualstudio.com/items?itemName=shopify.ruby-lsp

https://marketplace.visualstudio.com/items?itemName=misogi.ruby-rubocop

https://marketplace.visualstudio.com/items?itemName=kaiwood.endwise

https://marketplace.visualstudio.com/items?itemName=KoichiSasada.vscode-rdbg

Debugging with VS Code

  • Install VSCode rdbg

  • Run the Debug Rails task

  • Enjoy inline VS Code debugging with breakpoints and everything

VS Code with rdbg

How to run

rbenv install 3.2.2 #to get the latest version of ruby gem install bundler # to get bundler installed bundle # install dependencies rails db:create # create database make migrate make dev 

Run scripts

make dev make test #all tests make test:swag make test:unit #services make migrate make swagger 

Miscellaneous

Any other additions are welcome!

About

Rails 7 REST (openapi) template repo with Dockerfile, docker-compose and docker-swarm stack

Topics

Resources

Stars

Watchers

Forks

Languages