{"id":13492940,"url":"https://github.com/guilleiguaran/nancy","last_synced_at":"2025-04-13T06:37:29.323Z","repository":{"id":3416196,"uuid":"3743483","full_name":"guilleiguaran/nancy","owner":"guilleiguaran","description":"Minimal Ruby microframework for web development inspired in Sinatra and Cuba.","archived":false,"fork":false,"pushed_at":"2023-05-26T08:40:26.000Z","size":74,"stargazers_count":83,"open_issues_count":1,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T10:48:54.844Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://guilleiguaran.github.com/nancy","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/guilleiguaran.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2012-03-16T21:58:45.000Z","updated_at":"2025-02-14T11:14:33.000Z","dependencies_parsed_at":"2022-07-23T10:46:38.866Z","dependency_job_id":null,"html_url":"https://github.com/guilleiguaran/nancy","commit_stats":{"total_commits":68,"total_committers":2,"mean_commits":34.0,"dds":"0.014705882352941124","last_synced_commit":"b3d9e74edee49298a17f360a4567d90c63ad0c55"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guilleiguaran%2Fnancy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guilleiguaran%2Fnancy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guilleiguaran%2Fnancy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guilleiguaran%2Fnancy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guilleiguaran","download_url":"https://codeload.github.com/guilleiguaran/nancy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248675351,"owners_count":21143763,"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":[],"created_at":"2024-07-31T19:01:10.638Z","updated_at":"2025-04-13T06:37:29.300Z","avatar_url":"https://github.com/guilleiguaran.png","language":"Ruby","funding_links":[],"categories":["Micro Frameworks inspired by Sinatra","Frameworks"],"sub_categories":[],"readme":"# Nancy\n_Sinatra's little daughter_\n\n![Frank and Nancy by classic film scans](http://farm6.staticflickr.com/5212/5386187897_e3155cec68.jpg)\n\n\n## Description\n\nMinimal Ruby microframework for web development inspired in [Sinatra](http://www.sinatrarb.com/) and [Cuba](https://github.com/soveran/cuba)\n\nRequires Ruby 2.7 or greater.\n\n## Installation\n\nInstall the gem:\n\n    $ gem install nancy\n\nor add it to your Gemfile:\n\n    gem \"nancy\"\n\n\n## Usage\n\nHere's a simple application:\n\n```ruby\n# hello.rb\nrequire \"nancy\"\nrequire \"nancy/render\"\n\nclass Hello \u003c Nancy::Base\n  use Rack::Session::Cookie, secret: ENV['SECRET_TOKEN'] # for sessions\n  include Nancy::Render\n\n  get \"/\" do\n    \"Hello World\"\n  end\n\n  get \"/hello\" do\n    response.redirect \"/\"\n  end\n\n  get \"/hello/:name\" do\n    \"Hello #{params['name']}\"\n  end\n\n  post \"/hello\" do\n    \"Hello #{params['name']}\"\n  end\n\n  get \"/files/:root/*path\" do\n    \"From #{params['root']}, download #{params['path']}\"\n  end\n\n  get \"/template\" do\n    @message = \"Hello world\"\n    render(\"views/hello.erb\")\n  end\n\n  post \"/login\" do\n    @user = User.find(params['username'])\n    halt 401, \"unauthorized\" unless @user.authenticate(params['password'])\n    session[:authenticated] = true\n    render(\"views/layout.erb\") { render(\"views/welcome.erb\") }\n  end\n\n  before(\"/protected\") do\n    halt 401, \"unauthorized\" unless session[:authenticated]\n  end\n\n  get \"/protected\" do\n    \"Protected area!!!\"\n  end\n\n  after(\".{+extension}\") do |params|\n    case params['extension']\n    when 'json'\n      response['Content-Type'] = 'application/json'\n    else\n      response['Content-Type'] = 'text/html'\n    end\n  end\n\n  get \"/users/:id.json\" do\n    @user = User.find(params['id'])\n    halt 404 unless @user\n    UserSerializer.new(@user).to_json\n  end\n\n  map \"/resque\" do\n    run Resque::Server\n  end\n\n  map \"/nancy\" do\n    run AnotherNancyApp.new\n  end\nend\n```\n\nTo run it, you can create a `config.ru` file:\n\n```ruby\n# config.ru\nrequire \"./hello\"\n\nrun Hello.new\n```\n\nYou can now run `rackup` and enjoy what you have just created.\n\nCheck examples folder for a detailed example.\n\n\n## Features\n*  Very fast\n*  \"Sinatra-like\" routes: support for get, post, put, patch, delete, options, head\n*  Template rendering and caching through Tilt or ERB from stdlib\n*  Set basic filters/callbacks with the before/after methods\n*  Include middlewares with the use method\n*  Mount rack apps with the map method\n*  Sessions through Rack::Session\n*  Halt execution at any point using Ruby's throw/catch mechanism\n*  Thread-safe\n\n\n## Version history\n\n### 0.6.0 (unreleased)\n*   Now requires ruby 2.7; version contains fixes for modern ruby and rack\n\n### 0.5.0 (unreleased)\n*   Switches the routing backend to sinatra/mustermann, supporting wildcard routes,\n    optional parameters, etc.\n\n### 0.4.0 (unreleased)\n*   Added support for basic before/after filters\n*   Added Nancy::BasicRender for rendering of templates using ``ERB`` from stdlib\n*   Refactored full code to set proper accessors for all methods\n*   Removed Nancy::Base.call, only instances can be used to run apps\n*   Removed redirect helper, use instead ``response.redirect '/uri'``\n*   Nancy::Render is not loaded automatically, \"nancy/render\" needs to be required\n*   Removed ``tilt`` dependency, to use Nancy::Render add it manually to app\n*   Nancy::Base#halt can't be used with a ``Rack::Response`` object anymore\n\n### 0.3.0 (Octuber 3, 2012)\n*   Removed unneccesary Thread accessors, use simple instance getters instead\n*   Refactored Nancy::Base#halt\n\n### 0.2.0 (April 12, 2012)\n\n*   Set PATH INFO to '/' when is blank\n*   Fixed session method: Raise error when is used but Rack::Session isn't present\n*   Added support for HEAD and OPTIONS HTTP verbs\n*   Refactored Base.use to use a Rack::Builder internally\n*   Added Base.map to redirect requests to Rack sub-apps\n\n### 0.1.0 (April 4, 2012)\n\n*   Created a new [Github Page](http://guilleiguaran.github.com/nancy) for the project\n*   Added env accessor, this add support for [Shield](https://github.com/cyx/shield)\n*   Added support for templates caching using Tilt::Cache\n*   Moved render method from Nancy::Base to Nancy::Render module\n*   Refactored Nancy::Base to evaluate code blocks at instance level\n*   Fixed passing of render options to Tilt (thanks to [lporras](https://github.com/lporras))\n\n### 0.0.1 (March 20, 2012)\n\n*   Initial Release\n\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n\n## Copyright\n\nCopyright (c) 2012-2014 Guillermo Iguaran. See LICENSE for\nfurther details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguilleiguaran%2Fnancy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguilleiguaran%2Fnancy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguilleiguaran%2Fnancy/lists"}