{"id":16878389,"url":"https://github.com/duffn/grape-api-boilerplate","last_synced_at":"2025-03-23T16:32:58.056Z","repository":{"id":37262659,"uuid":"505509048","full_name":"duffn/grape-api-boilerplate","owner":"duffn","description":"A full-featured, production ready, and easy to understand API boilerplate for the Grape framework.","archived":false,"fork":false,"pushed_at":"2024-05-28T12:30:21.000Z","size":2313,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-29T04:02:22.747Z","etag":null,"topics":["api","boilerplate","grape","grape-api","hacktoberfest","rack","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/duffn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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}},"created_at":"2022-06-20T16:02:50.000Z","updated_at":"2024-05-31T13:26:21.207Z","dependencies_parsed_at":"2023-02-14T17:46:11.701Z","dependency_job_id":"eb34658b-a57d-4608-8524-502c1eff9294","html_url":"https://github.com/duffn/grape-api-boilerplate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duffn%2Fgrape-api-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duffn%2Fgrape-api-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duffn%2Fgrape-api-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duffn%2Fgrape-api-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duffn","download_url":"https://codeload.github.com/duffn/grape-api-boilerplate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245131333,"owners_count":20565803,"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","boilerplate","grape","grape-api","hacktoberfest","rack","ruby"],"created_at":"2024-10-13T15:48:44.771Z","updated_at":"2025-03-23T16:32:58.047Z","avatar_url":"https://github.com/duffn.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grape-api-boilerplate\n\n[![Tests](https://github.com/duffn/grape-api-boilerplate/actions/workflows/test.yml/badge.svg)](https://github.com/duffn/grape-api-boilerplate/actions/workflows/test.yml) [![Rubocop](https://github.com/duffn/grape-api-boilerplate/actions/workflows/rubocop.yml/badge.svg)](https://github.com/duffn/grape-api-boilerplate/actions/workflows/rubocop.yml) [![codecov](https://codecov.io/gh/duffn/grape-api-boilerplate/branch/main/graph/badge.svg?token=QWUQKQU3X1)](https://codecov.io/gh/duffn/grape-api-boilerplat)\n\nA full-featured, production ready, and easy to understand API boilerplate for\nthe [Grape framework](https://github.com/ruby-grape/grape).\n\n## Features\n\n- Local development with [Docker](https://www.docker.com/) and Docker Compose.\n- Automatic Puma reloading locally with [`guard-puma`](https://github.com/jc00ke/guard-puma).\n- ActiveRecord with [`otr-activerecord`](https://github.com/jhollinger/otr-activerecord).\n- Swagger API documentation with [`grape-swagger`](https://github.com/ruby-grape/grape-swagger).\n- User authentication with [`bcrypt`](https://github.com/bcrypt-ruby/bcrypt-ruby)\n  using [`jwt`](https://github.com/jwt/ruby-jwt).\n- Model pagination with [`api-pagination`](https://github.com/davidcelis/api-pagination).\n- Standard security headers with [`secure_headers`](https://github.com/github/secure_headers).\n- Monitoring and alerting with [Sentry](https://sentry.io) and[Prometheus](https://prometheus.io).\n- Comprehensive [RSpec](https://rspec.info/) test suite and code coverage.\n\n## Running\n\n- Generate a key pair for local JWT authentication.\n\n```\ncd grape-api-boilerplate/config/jwt\nssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key\nopenssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub\n```\n\n- Build and run with Docker Compose.\n\n```\ndocker compose up --build\n```\n\n- Setup and seed the database.\n\n```\ndocker compose exec app bundle exec rake db:setup\n```\n\n- Visit your API at http://localhost:3000\n\n## Creating a user\n\n- Run the create users Rake task.\n\n```\ndocker compose run --rm app bundle exec rake users:create\n```\n\n- Enter your desired email, username, and password.\n\n## Authentication and requests\n\n- Hello world.\n\n```\ncurl http://localhost:3000/api/v1/hello | jq .\n```\n\n- Authenticate and authenticated request.\n\n```\n# Authenticate with the test user.\ntoken=$(curl -XPOST \\\n  -H \"Content-Type:application/json\" \\\n  -d '{\"username\":\"grape_user\",\"password\":\"grape_user1\"}' \\\n  http://localhost:3000/api/login | jq -r '.token')\n\ncurl -H \"Authorization: Bearer ${token}\" \\\n  http://localhost:3000/api/v1/widget | jq .\n```\n\n## Tests\n\n- Run linting and tests.\n\n```\ndocker compose run --rm -e RACK_ENV=test app bundle exec rake\n```\n\n## API documentation\n\nWhen running locally, you can visit http://localhost:3000/public/swagger/index.html to view your Swagger API\ndocumentation.\n\n## Production\n\n### Sentry\n\nYou can enable [Sentry](https://sentry.io/) for your API by setting `sentry.enabled` in your settings file(s).\n\n- Update the setting in `app/settings/\u003cenvironment\u003e.yml`.\n\n```yaml\nsentry:\n  enabled: true\n```\n\n- Add your Sentry DSN to a `SENTRY_DSN` environment variable.\n\n- See the [Sentry Rack guide](https://docs.sentry.io/platforms/ruby/guides/rack/) for more.\n\n### Prometheus\n\nYou can enable [Prometheus](https://prometheus.io/) metrics for your API by setting `prometheus.enabled` in your production settings file.\n\n- Update the setting in `app/settings/production.yml`.\n\n```yaml\nprometheus:\n  enabled: true\n```\n\n- The default middleware will provide some basic metrics out of the box. See the [Ruby Prometheus client library documentation](https://github.com/prometheus/client_ruby) for advanced usage.\n\n_Note_: Prometheus metrics should not be exposed publicly! Please ensure you know what you're doing before enabling this feature in your environment.\n\n### Docker\n\nBuild a production ready image with the [`Dockerfile`](Dockerfile) and deploy to your favorite platform.\n\n```\ndocker build -t grape-api-boilerplate:latest .\n```\n\n## Contributing\n\nContributions are welcome! See [CONTRIBUTING](CONTRIBUTING.md).\n\n## License\n\nMIT License. See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduffn%2Fgrape-api-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduffn%2Fgrape-api-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduffn%2Fgrape-api-boilerplate/lists"}