{"id":13879204,"url":"https://github.com/joshmn/jeanine","last_synced_at":"2025-04-22T15:44:23.492Z","repository":{"id":39685523,"uuid":"277937755","full_name":"joshmn/jeanine","owner":"joshmn","description":"A lightning-fast, batteries-included Ruby web micro-framework.","archived":false,"fork":false,"pushed_at":"2023-03-16T06:43:41.000Z","size":307,"stargazers_count":14,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T19:14:27.855Z","etag":null,"topics":["microframework","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joshmn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-07T22:48:28.000Z","updated_at":"2023-08-03T07:34:05.000Z","dependencies_parsed_at":"2023-02-10T18:15:25.923Z","dependency_job_id":null,"html_url":"https://github.com/joshmn/jeanine","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshmn%2Fjeanine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshmn%2Fjeanine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshmn%2Fjeanine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshmn%2Fjeanine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshmn","download_url":"https://codeload.github.com/joshmn/jeanine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250270924,"owners_count":21403090,"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":["microframework","ruby"],"created_at":"2024-08-06T08:02:13.323Z","updated_at":"2025-04-22T15:44:23.468Z","avatar_url":"https://github.com/joshmn.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Jeanine\n\nA Ruby micro-web-framework that gives you enough training wheels to be productive, while being as nearly as fast as Rack itself.\n\nIts design (and some parts of the code) is influenced by/inherited from (thanks!) Ruby on Rails, Rack::App, Hobbit, and Cuba. Without them this is nothing.\n\n![jeanine logo](jeanine.png)\n\n## Name \n\nNamed after my mom. Because she was the best.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'jeanine'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install jeanine\n\n## Basic usage\n\nDrop this into `config.ru`:\n\n```ruby\nrequire 'bundler/setup'\nrequire 'jeanine'\n\nclass App \u003c Jeanine::App\n  root do\n    \"Hello world\"\n  end\nend\n\nrun App \n```\n\n`$ rackup`\n\nOr generate a new app:\n\n```\n$ gem install jeanine\n$ jeanine new my_api\n$ cd my_api\n$ bundle\n$ rackup \n```\n\n## Advanced usage \n\n```ruby\nclass App \u003c Jeanine::App \n  path \"/posts\" do \n    get do \n      if request.json?\n        render json: []\n      else\n        \"Posts index\"\n      end\n    end \n    \n    get \"new\" do \n      \"Posts new\"\n    end\n    \n    post do \n      \"Posts post\"\n    end \n    \n    path \":id\" do \n      get do \n        \"Posts #{params[:id]}\"\n      end\n      \n      match via: [:put, :patch] do \n        \"Posts #{request.via} #{params[:id]}\"\n      end\n      \n      delete do\n        \"Posts delete #{params[:id]}\" \n      end \n      \n      path \"/comments\" do\n        get do \n          \"Posts #{params[:id]} comments\"\n        end \n      end\n    end \n  end \nend \n```\n\n## Plugins \n\n### Callbacks \n\nSupports `before` and `after` callbacks (same DSL): \n\n```ruby\nclass App \u003c Jeanine::App\n  plugin :Callbacks \n  \n  before do \n    puts \"All\"\n  end\n  \n  before /posts/ do\n    puts \"Before posts\"\n  end \n  \n  before /posts\\/\\d*/, /comments\\/\\d*/  do \n    puts \"Before posts/:id, comments/:id\"\n    response.headers['X-Thing-Id'] = params[:id]\n  end \nend \n```\n\n### Rendering\n\nBasic support for rendering. Be explicit.\n\n```ruby \nclass App \u003c Jeanine::App\n  plugin :Rendering \n  \n  # loads views/root.html.erb and views/layouts/application.html.erb\n  root do \n    @title = \"My cool app\"\n    render template: \"root.html.erb\", layout: \"application.html.erb\"\n  end\nend \n```\n\n### Sessions\n\nUses Rack's session management.\n\n```ruby\nclass App \u003c Jeanine::App\n  plugin :Session\n  \n  root do \n    session[:uid] = SecureRandom.hex\n  end\nend \n```\n\n### Error handling\n\n```ruby\nclass App \u003c Jeanine::App\n  plugin :Rescuable \n  \n  rescue_from NoMethodError, RuntimeError do |exception|\n    response.status = 500\n    \"Oh no!\"\n  end\n  \n  rescue_from StandardError, with: :handle_error!\n  \n  root do \n    @title = \"My cool app\"\n    raise NoMethodError \n    render template: \"root.html.erb\", layout: \"application.html.erb\"\n  end\n\n  private \n  \n  def handle_error!(exception)\n    response.status = 500\n    render template: \"error.html.erb\" \n  end\nend \n```\n\n## Development\n\n### Ideologies\n\n* No meaningless metaprogramming = fast \n\n## Benchmarks \n\n### Requests/second\n\nBenched on a Intel Core i7-8700B / 64GB RAM.\n\n```\nFramework            Requests/sec  % from best\n----------------------------------------------\nrack                     17299.31      100.00%\njeanine                  16022.71       92.62%\nrack-response            15462.50       89.38%\nsyro                     15416.13       89.11%\nwatts                    15307.52       88.49%\nroda                     14550.56       84.11%\nhanami-router            14342.92       82.91%\ncuba                     14246.23       82.35%\nhobbit                   14132.20       81.69%\nrambutan                 12526.40       72.41%\nrack-app                 11696.66       67.61%\nflame                     7931.61       45.85%\nrails-metal               7761.75       44.87%\nsinatra                   4616.81       26.69%\ngrape                     2401.66       13.88%\nhobby                     1805.93       10.44%\nrails-api                 1593.77        9.21%\n```\n\n### Memory\n\n```\nFramework       Allocs/Req Memsize/Req\n--------------------------------------\nrack                    40        3408\nroda                    43        4016\nsyro                    44        4288\ncuba                    44        4056\nwatts                   46        3648\nhobbit                  48        4416\njeanine                 52        4576\nhobby                   52        5416\nrack-response           55        5128\nrails-metal             59        5848\nhanami-router           63        5184\nrambutan                79        6944\nrack-app                80        8424\nflame                  115        9648\nsinatra                179       13440\ngrape                  250       26704\nrails-api              383       34949\n```\n\n## Todo \n\n* Callback constraints \n* File downloads \n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/joshmn/jeanine.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshmn%2Fjeanine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshmn%2Fjeanine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshmn%2Fjeanine/lists"}