{"id":13492960,"url":"https://github.com/rack-app/rack-app","last_synced_at":"2025-05-15T18:07:40.939Z","repository":{"id":54626462,"uuid":"43595136","full_name":"rack-app/rack-app","owner":"rack-app","description":"minimalist framework for building rack applications","archived":false,"fork":false,"pushed_at":"2023-11-15T19:08:48.000Z","size":1888,"stargazers_count":413,"open_issues_count":3,"forks_count":20,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-31T23:33:40.213Z","etag":null,"topics":["api","rack","rack-apps","ruby","ruby-framework","web-app","web-application-framework","web-application-frameworks"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rack-app.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-03T10:11:18.000Z","updated_at":"2025-03-29T16:02:32.000Z","dependencies_parsed_at":"2023-11-15T01:40:07.986Z","dependency_job_id":"10c13c93-384a-41ee-b7e8-659f032ac21a","html_url":"https://github.com/rack-app/rack-app","commit_stats":{"total_commits":552,"total_committers":13,"mean_commits":42.46153846153846,"dds":0.04528985507246375,"last_synced_commit":"1f1f6b1aee1766c5c7ba6454e1da89c3b8f3a037"},"previous_names":[],"tags_count":123,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rack-app%2Frack-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rack-app%2Frack-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rack-app%2Frack-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rack-app%2Frack-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rack-app","download_url":"https://codeload.github.com/rack-app/rack-app/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247755557,"owners_count":20990620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","rack","rack-apps","ruby","ruby-framework","web-app","web-application-framework","web-application-frameworks"],"created_at":"2024-07-31T19:01:10.851Z","updated_at":"2025-04-08T00:35:20.634Z","avatar_url":"https://github.com/rack-app.png","language":"Ruby","readme":"# [Rack::App](https://github.com/rack-app/rack-app)\n\n![rack-app-logo](/assets/rack-app-logo.png)\n\n[rack-app GPT assistant](https://chat.openai.com/g/g-DOKIpY8aq-rack-app)\n\n`rack-app` is a minimalist web framework that focuses on simplicity and maintainability.\nThe framework is meant to be used by seasoned web developers.\n\n`rack-app` focus on keeping the dependencies as little as possible,\nwhile allowing writing functional and minimalist rack-based applications,\nthat will do nothing more than what you defined.\n\nThe routing uses a prefix tree,\nthus adding a large number of API endpoints won't affect the routing lookup time.\n\nIt was inspirited by `Sinatra`, `grape`, and `rack`.\nIt's used in production, powering back-end APIs running on the public cloud.\n\n## Development Status\n\nThe framework is considered stable.\nI don't have the plan to feature creep the framework without real-life use-cases,\nsince most of the custom edge cases can be resolved with composition.\n\nThe next time it will receive further updates,\nwhen rack provides a finalized support for http2.\n\nIf you have an issue, I weekly check the issues tab,\nanswer and reply, or implement a fix for it.\n\nSince the framework's only dependency is the `rack` gem,\nI don't have to update the codebase too often.\n\nCheers and Happy Coding!\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'rack-app'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install rack-app\n\n\n## Is it Production ready?\n\nYes, it's already powering Heroku hosted micro-services.\n\n## Principles\n\n* Keep It Simple\n* No Code bloat\n* No on run time processing, or keep at the bare minimum\n* Fully BDD (Behaviour Driven Design)\n  * built-in test module to ease the development with easy to use tests\n* Easy to Learn\n  * rack-app use well known and easy to understand conventions, such as sinatra like DSL\n* Principle Of Least Surprise\n* Modular design\n* the Only dependency is rack, nothing more\n* Open development\n* Try to create Examples for every feature\n\n## Features\n\n* Easy to understand syntax\n  * module method level endpoint definition inspirited heavily by the Sinatra DSL\n  * unified error handling\n  * syntax sugar for default header definitions\n  * namespaces for endpoint request path declarations so it can be dry and unified\n* no Class method bloat, so you can enjoy pure ruby without any surprises\n* App mounting so you can create separated controllers for different task\n* Streaming\n* O(log(n)) lookup routing\n  * allows as many endpoint registrations to you as you want, without impact on route lookup speed\n* only basic sets for instance method level for the must need tools, such as params, payload\n* Simple to use class level response serializer\n  * so you can choose what type of serialization you want without any enforced convention\n* static file serving so you can mount even filesystem-based endpoints too\n* built-in testing module so your app can be easily written with BDD approach\n* made with minimalism in mind so your app can't rely on the framework when you implement business logic\n  * if you need something, you should implement it without any dependency on a web framework, rack-app only mean to be to provide you with easy to use interface to the web layer, nothing less and nothing more\n* per endpoint middleware definitions\n  * you can define middleware stack before endpoints and it will only apply to them, similar like protected method workflow\n* File Upload and file download efficiently and elegantly with minimal memory consuming\n  * note that this is not only memory friendly way pure rack solution, but also 2x faster than the usual solution which includes buffering in memory\n* params validation with ease\n\n## Under the hood\n\nrack-app's router relies on a tree structure which makes heavy use of *common prefixes*,\nit is basically a *compact* [*prefix tree*](https://en.wikipedia.org/wiki/Trie) (or just [*Radix tree*](https://en.wikipedia.org/wiki/Radix_tree)).\nNodes with a common prefix also share a common parent.\n\n## Contributors\n\n* **[Daniel Nagy](https://github.com/thilonel)**\n\n  * Serializer MVP implementation\n\n* **[Daniel Szpisjak](https://github.com/felin-arch)**\n\n  * Pimp up the website descriptions\n\n* **[Jeremy Evans](https://github.com/jeremyevans)**\n\n  * suggestion for application stand up speed optimization\n\n* **[David Bush](https://github.com/disavowd)**\n\n  * [wrote an awesome article](https://www.sitepoint.com/rack-app-a-performant-and-pragmatic-web-microframework/) about the project\n\n* **[TheSmartnik](https://github.com/TheSmartnik)**\n\n  * Clarify examples in the documentation\n\n## [Contributing](CONTRIBUTING.md)\n\n## Usage\n\n#### basic\n\n```ruby\n\nrequire 'rack/app'\n\nclass App \u003c Rack::App\n\n  desc 'some hello endpoint'\n  get '/hello' do\n    'Hello World!'\n  end\n\nend\n\n```\n\n#### complex\n\n```ruby\n\nrequire 'rack/app'\n\nclass App \u003c Rack::App\n\n  mount SomeAppClass\n\n  headers 'Access-Control-Allow-Origin' =\u003e '*',\n          'Access-Control-Expose-Headers' =\u003e 'X-My-Custom-Header, X-Another-Custom-Header'\n\n  serializer do |object|\n    object.to_s\n  end\n\n  desc 'some hello endpoint'\n  validate_params do\n    required 'words', :class =\u003e Array, :of =\u003e String, :desc =\u003e 'some word', :example =\u003e ['pug']\n    optional 'word', :class =\u003e String, :desc =\u003e 'one word', :example =\u003e 'pug'\n    optional 'boolean', :class =\u003e :boolean, :desc =\u003e 'boolean value', :example =\u003e true\n  end\n  get '/hello' do\n    puts(params['words'])\n\n    'Hello World!'\n  end\n\n  namespace '/users' do\n\n    desc 'some restful endpoint'\n    get '/:user_id' do\n      response.status = 201\n      params['user_id'] #=\u003e restful parameter :user_id\n      say #=\u003e \"hello world!\"\n    end\n\n  end\n\n  desc 'some endpoint that has error and will be rescued'\n  get '/make_error' do\n    raise(StandardError,'error block rescued')\n  end\n\n  def say\n    \"hello #{params['user_id']}!\"\n  end\n\n  error StandardError, NoMethodError do |ex|\n    {:error=\u003eex.message}\n  end\n\n  root '/hello'\n\n  get '/stream' do\n    stream do |out|\n      out \u003c\u003c 'data row'\n    end\n  end\n\nend\n\n```\n\nyou can access Rack::Request with the request method and\nRack::Response as a response method.\n\nBy default, if you don't write anything to the response 'body' the endpoint block logic return will be used\n\n### Frontend Example\n\nif you don't mind extending your dependency list then you can use the front_end extension for creating template-based web applications.\n\n```ruby\nrequire 'rack/app'\nrequire 'rack/app/front_end' # You need to add `gem 'rack-app-front_end'` to your Gemfile\n\nclass App \u003c Rack::App\n\n  apply_extensions :front_end\n\n  helpers do\n\n    def method_that_can_be_used_in_template\n      'hello world!'\n    end\n\n  end\n\n  # use ./app/layout.html.erb as layout, this is optionable\n  layout 'layout.html.erb'\n\n  # at '/' the endpoint will serve (render)\n  # the ./app/index.html content as response body and wrap around with layout if the layout is given\n  get '/' do\n    render 'index.html'\n  end\n\nend\n```\n\nthis example expects an \"app\" folder next to the \"app.rb\" file that included templates being used such as layout.html.erb and index.html.\n\n## Testing\n\nfor testing use rack/test or the bundled testing module for writing unit test for your rack application\n\n```ruby\n\nrequire 'spec_helper'\nrequire 'rack/app/test'\n\ndescribe App do\n\n  include Rack::App::Test\n\n  rack_app described_class\n\n  describe '/hello' do\n    # example for params and headers and payload use\n    subject { get(url: '/hello', params: {'dog' =\u003e 'meat'}, headers: {'X-Cat' =\u003e 'fur'}, payload: 'some string') }\n\n    it { expect(subject.status).to eq 200 }\n\n    it { expect(subject.body).to eq \"Hello World!\" }\n  end\n\n  describe '/users/:user_id' do\n    # restful endpoint example\n    subject { get(url: '/users/1234') }\n\n    it { expect(subject.body).to eq 'hello 1234!'}\n\n    it { expect(subject.status).to eq 201 }\n\n  end\n\n  describe '/make_error' do\n    # error handled example\n    subject { get(url: '/make_error') }\n\n    it { expect(subject.body).to eq '{:error=\u003e\"error block rescued\"}' }\n  end\n\nend\n\n\n```\n\n## Example Apps To start with\n\n* [Official website How To examples](https://github.com/rack-app/rack-app/wiki)\n\n* [Rack::App Team Github repositories](https://github.com/rack-app)\n\n* [Basic](https://github.com/rack-app/rack-app-example-basic)\n  * bare-bone simple example app\n\n* [Escher Authorized Api](https://github.com/rack-app/rack-app-example-escher)\n  * complex authorization for corporal level API use\n\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/rack-app/rack-app This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.\n\n## License and Copyright\n\nRack::App is free software released under the [Apache License V2](https://opensource.org/licenses/Apache-2.0) License.\nThe logo was designed by Zsófia Gebauer. It is Copyright © 2015 Adam Luzsi. All Rights Reserved.\n","funding_links":[],"categories":["Micro Frameworks inspired by Sinatra","Ruby","Web Frameworks","Frameworks"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frack-app%2Frack-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frack-app%2Frack-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frack-app%2Frack-app/lists"}