{"id":40773041,"url":"https://github.com/performant-software/resource-api","last_synced_at":"2026-01-21T18:56:18.734Z","repository":{"id":37905617,"uuid":"291042539","full_name":"performant-software/resource-api","owner":"performant-software","description":"A simple framework for building RESTFUL APIs in Rails","archived":false,"fork":false,"pushed_at":"2025-08-28T00:41:15.000Z","size":102,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-08-28T08:12:31.480Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/performant-software.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-08-28T12:35:57.000Z","updated_at":"2025-08-28T00:37:44.000Z","dependencies_parsed_at":"2023-12-20T07:29:58.097Z","dependency_job_id":"bd1e3f48-4442-4160-94ce-3262271ca445","html_url":"https://github.com/performant-software/resource-api","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/performant-software/resource-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/performant-software%2Fresource-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/performant-software%2Fresource-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/performant-software%2Fresource-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/performant-software%2Fresource-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/performant-software","download_url":"https://codeload.github.com/performant-software/resource-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/performant-software%2Fresource-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28639900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T18:04:35.752Z","status":"ssl_error","status_checked_at":"2026-01-21T18:03:55.054Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-01-21T18:56:17.889Z","updated_at":"2026-01-21T18:56:18.729Z","avatar_url":"https://github.com/performant-software.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Resource API\nThe Resource API gem is a framework for building a simple RESTFUL API in a Rails application. It provides bases classes that can be extended to customize the functionality to fit your needs.\n\n## Build\n```\ngem build resource-api.gemspec\n```\n\n## Installation\nUpdate your SSH config to use your SSH key to access the resource-api repository:\n\n```\n# ~/.ssh/config\n\nHost resource-api\n  HostName github.com\n  IdentityFile ~/.ssh/id_rsa\n```\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'resource_api', git: 'git@resource-api:performant-software/resource-api.git'\n```\n\nAnd then execute:\n```bash\n$ bundle install\n```\n\nOr install it yourself as:\n```bash\n$ gem install resource-api\n```\n\n## Usage\n\n#### Controllers\nControllers are setup in a way to perform based CRUD operations without much need for customization. Define your allowed parameters in your models (see below) and the controller will handle the rest. The `Api::ResourceController` also provides protected methods that can be overwritten or extended to customize functionality:\n```ruby\ndef apply_filters(query)\n  return query unless params[:homeroom].present?\n  \n  query.where(homeroom: params[:homeroom])\nend\n```\n\nThe `Api::ResourceController` uses the `Queryable` concern to build your query on the `#index` and `#show` routes. You can use the `preloads`, `joins`, `left_joins`, and `per_page` methods to optimize the query and avoid unnecessary queries during serialization.\n\n```ruby\nclass Api::StudentsController \u003c Api::ResourceController\n  per_page 20\n  preloads :school, :classes\nend\n```\n\n#### Models\nModels can be setup using the `Resourceable` concern to define strong parameters. The list of parameters can be acessed using `\u003cModelName\u003e.permitted_params` (i.e. `Student.permitted_params`). This is done automatically in the `Api::ResourceController` in order to enforce the appropriate parameters.\n\n```ruby\nclass Student \u003c ApplicationRecord\n  include Resourceable\n\n  belongs_to :school\n  has_many :classes, dependent: :destroy\n\n  accepts_nested_attributes_for :classes, allow_destroy: true\n\n  allow_params :first_name, :last_name, :yog, :dob, :homeroom,\n               classes_attributes: [:id, :section_id, :_destroy]\nend\n```\n\n#### Serializers\nSerializers use the `ObjectSerializer` concern to define which attributes to render and when.\n\nThe `index_attributes` and `belongs_to` attributes defined will be rendered on the `#index` route.\n\nThe `show_attributes`, `belongs_to`, and `has_many` attributes defined will be rendered on the `#show`, `#create`, and `#update` routes.\n\n```ruby\nclass StudentsSerializer \u003c BaseSerializer\n  index_attributes :id, :first_name, :last_name\n  \n  show_attributes :id, :first_name, :last_name, :yog, :dob, :homeroom\n  \n  has_many classes: [:id, :section_id]\n  \n  belongs_to school: SchoolsSerializer\nend\n```\n\n### Heroku\nWhen deploying to a staging server on Heroku, we'll need to allow Heroku access to the resource-api repository in order to install dependencies. This section will describe how to do that.\n\n#### Copy preinstall and postinstall scripts\nCopy the `preinstall.sh` and `postinstall.sh` scripts from this repository into your project. It doesn't matter where, but a directory named `scripts` is usually a good idea.\n\nModifications to the scripts may be necessary if using more than one private repo.\n\n#### Update package.json\nIn your root level `package.json`, add or append the following to the `scripts` object:\n```\n\"heroku-prebuild\": \"bash ./scripts/preinstall.sh\"\n\"heroku-postbuild\": \"bash ./scripts/postinstall.sh\"\n```\nThese two scripts will install your SSH key prebuild, then after the dependencies are installed, remove it.\n\nNote: The heroku-prebuild and heroku-postbuild scripts require the NodeJS buildpack. \n\nYou'll want to use the following syntax for defining the `resource_api` dependency in your Gemfile:\n\n```ruby\ngem 'resource_api', git: 'git@resource-api:performant-software/resource-api.git'\n```\n\nNote: `yarn` does not seem to work with the above syntax. It is recommended to use `npm`.\n\n#### Generate a deploy key\nFrom your computer, generate a new public/private SSH key pair using the following command and save the key pair somewhere secure.\n```\nssh-keygen -t rsa\n```\n\nCopy the public key using:\n```\npbcopy \u003c my-awesome-project-staging-deploy-key.pub\n```\n\nWithin the resource-api repository on GitHub, go to Settings \u003e Deploy Keys. Add the copied public key for your project. Name it something obvious like \"My Awesome Project Staging\" so that others will know what it is used for.\n\n#### Add your deploy key to Heroku\nConvert the private key from PEM to base64 using the following command and copy the value.\n```\ncat my-awesome-project-staging-deploy-key | base64\n```\n\nIn the Heroku dashboard for your app, navigate to the Settings tab. Add a config var with key `RESOURCE_API_SSH_KEY` and paste the value copied from the private deploy key.\n\n## License\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%2Fperformant-software%2Fresource-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperformant-software%2Fresource-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperformant-software%2Fresource-api/lists"}