{"id":24748060,"url":"https://github.com/codingitwrong/apiup","last_synced_at":"2025-10-24T00:30:15.606Z","repository":{"id":44595140,"uuid":"143284422","full_name":"CodingItWrong/apiup","owner":"CodingItWrong","description":"Create a Rails API pre-configured for JSON:API and OAuth 2 authentication","archived":false,"fork":false,"pushed_at":"2023-04-22T13:31:23.000Z","size":58,"stargazers_count":16,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-04T01:11:46.704Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CodingItWrong.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":"2018-08-02T11:14:49.000Z","updated_at":"2023-08-14T13:30:05.000Z","dependencies_parsed_at":"2023-01-31T11:30:45.267Z","dependency_job_id":null,"html_url":"https://github.com/CodingItWrong/apiup","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CodingItWrong/apiup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodingItWrong%2Fapiup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodingItWrong%2Fapiup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodingItWrong%2Fapiup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodingItWrong%2Fapiup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodingItWrong","download_url":"https://codeload.github.com/CodingItWrong/apiup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodingItWrong%2Fapiup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279004706,"owners_count":26083750,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2025-01-28T05:18:26.569Z","updated_at":"2025-10-10T16:31:36.633Z","avatar_url":"https://github.com/CodingItWrong.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# apiup\n\nCreates a new Rails API pre-configured for JSON API and OAuth 2 authentication:\n\n- Configures [JSONAPI::Resources](http://jsonapi-resources.com/) for [JSON API](http://jsonapi.org/)\n- Configures [Doorkeeper](https://github.com/doorkeeper-gem/doorkeeper) for OAuth 2 authentication\n- Creates a User model with [`has_secure_password`](https://api.rubyonrails.org/classes/ActiveModel/SecurePassword/ClassMethods.html#method-i-has_secure_password) for password storage\n- Sets up a `POST /users` endpoint for registration\n- Configures [factory_bot](https://github.com/thoughtbot/factory_bot) factories for User and access tokens to make request specs easy\n- Passes the `current_user` to JSONAPI::Resources\n\nAlso includes the following setup:\n\n- Enables Rails API mode\n- Removes Action Cable, Active Storage, and Bootsnap\n- Uses Postgres instead of SQLite\n- Uses [RSpec](http://rspec.info/) instead of Minitest\n- Disables authenticity token\n- Enables [CORS](https://github.com/cyu/rack-cors)\n- Configures a CircleCI configuration file for continuous integration\n- Adds:\n  - [Bullet](https://github.com/flyerhzm/bullet)\n  - [Dotenv](https://github.com/bkeepers/dotenv)\n  - [Faker](https://github.com/stympy/faker)\n  - [Rack-Attack](https://github.com/kickstarter/rack-attack)\n\nTo learn more, see [\"Authorizing jsonapi_resources\"](https://www.bignerdranch.com/blog/authorizing-jsonapi-resources-part-1-visibility/).\n\n## Installation\n\nDownload the repo, then run `bin/apiup NEW-APP-NAME`.\n\nTo be able to run `apiup` from anywhere, add the repo's `bin` directory to your `PATH`.\n\n## Usage\n\nYou can set up your API using typical Rails, JSONAPI::Resources, and Doorkeeper features. Here are some common first steps.\n\n### Creating a model\n\nSay you're creating a project management app. Start with generating a Project model:\n\n```sh\n$ rails generate model project name:string\n```\n\nYou can add `field:type` pairs to automatically add them:\n\nThe list of available types is at \u003chttps://api.rubyonrails.org/v5.2.1/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_column\u003e\n\nIf you want a record to be connected to another record, add the name of that model, with the `:references` field type. For example, to associate the record with a user, add `user:references`.\n\n### Creating a resource\n\nResources control the public view of your model that is exposed. This is the main class you'll modify.\n\n```sh\n$ rails generate jsonapi:resource project\n```\n\nThen update the resource to inherit from `ApplicationResource`.\n\nAdd each attribute you want publicly visible. Add each `has_many` or `has_one` relationship you want to expose as well:\n\n```ruby\nclass ProjectResource \u003c ApplicationResource\n  attribute :name\n  has_many :stories\nend\n```\n\nIf you want to automatically assign a created record to the logged-in user, pass a blog to `before_create` (note that `current_user` will only be available if you inherit from `ApplicationResource`):\n\n```ruby\nbefore_create do\n  _model.user = current_user\nend\n```\n\nYou may also want to prevent manually assigning the `user` by removing it from the list of creatable and updatable fields:\n\n```ruby\ndef self.creatable_fields(context)\n  super - [:user]\nend\n\ndef self.updatable_fields(context)\n  super - [:user]\nend\n```\n\nIf you want to limit the records shown, override `self.records`. For example, to return only records belonging to the current user:\n\n```ruby\ndef self.records(options = {})\n  user = current_user(options)\n  user.projects\nend\n```\n\n(Note that the class method `current_user` requires `options` to be passed to it, whereas the instance method `current_user` does not.)\n\n### Creating a controller\n\nTo create a controller for a JSON:API resource:\n\n```sh\n$ rails generate jsonapi:controller projects\n```\n\nUpdate the controller to inherit from `ApplicationController`. This disables CSRF and makes the `current_user` available to the resources.\n\nIf you don't want a controller to be available to users who aren't logged in, add:\n\n```ruby\nbefore_action :doorkeeper_authorize!\n```\n\nYou shouldn't need to customize anything else in the controller.\n\n### Adding routes\n\nAdd the following to `routes.rb`:\n\n```ruby\njsonapi_resources :projects\n```\n\nNot only will `jsonapi_resources` add the routes for the projects model, it will also add nested routes for any models related to projects.\n\n## Thanks\n\nBased on [this blog post](http://iamvery.com/2015/02/17/rails-new-for-you.html) by [iamvery](https://github.com/iamvery).\n\n## License\n\nApache-2.0. See `License.txt` for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodingitwrong%2Fapiup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodingitwrong%2Fapiup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodingitwrong%2Fapiup/lists"}