A Sinatra 4 JSON API starter in Ruby 3.2, written in modular style and served by Puma through Rack. It is for Ruby developers who want a minimal API skeleton with JSON error responses and Minitest already set up.
by Light CloudREST APIs
Settings, the json helper and the not_found and error handlers sit in app/application.rb, and each file in app/routes/ is a module with self.registered(app) that the app pulls in with register. That keeps the class small as you add resources, and it mounts in Rack or tests without global state. There is only a root route, so the first job is a new module such as Routes::Things, and maybe a /health route for monitoring. Light Cloud runs it with bundle exec rackup on PORT and APP_ENV=production, redeploying on each push to your copy.
Create a module in app/routes/ shaped like root.rb, with a self.registered(app) method that calls app.get, app.post and so on. Then require_relative it in app/application.rb and add register Routes::YourModule.
Classic style defines routes at the top level of a script. Modular style, used here, puts the app in a Sinatra::Base subclass that Rack, tests and other apps can mount without global state.
Define not_found and error blocks that return JSON, as app/application.rb does, and turn off show_exceptions so Sinatra does not send its HTML error page instead.
No. Restart bundle exec rackup -p 3000 after a change, or add a reloader gem such as rerun to the development group.
Yes. It is a plain Rack app: any host with Ruby 3.2 runs it with bundle exec rackup -p $PORT -o 0.0.0.0 and APP_ENV=production, and any server that reads config.ru works too.
Start a Flask JSON API with an app factory and a real WSGI server, not flask run
Start a PHP JSON API on Slim 4 without the weight of a full framework
Start a Node.js REST API with Express, CORS, JSON errors and tests already wired up