Skip to content

A full-featured, production ready, and easy to understand API boilerplate for the Grape framework.

License

Notifications You must be signed in to change notification settings

duffn/grape-api-boilerplate

Repository files navigation

grape-api-boilerplate

Tests Rubocop codecov

A full-featured, production ready, and easy to understand API boilerplate for the Grape framework.

Features

Running

  • Generate a key pair for local JWT authentication.
cd grape-api-boilerplate/config/jwt
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
  • Build and run with Docker Compose.
docker compose up --build
  • Setup and seed the database.
docker compose exec app bundle exec rake db:setup

Creating a user

  • Run the create users Rake task.
docker compose run --rm app bundle exec rake users:create
  • Enter your desired email, username, and password.

Tests

  • Run linting and tests.
docker compose run --rm -e RACK_ENV=test app bundle exec rake

API documentation

When running locally, you can visit http://localhost:3000/public/swagger/index.html to view your Swagger API documentation.

Production

Sentry

You can enable Sentry for your API by setting sentry.enabled in your settings file(s).

  • Update the setting in app/settings/<environment>.yml.
sentry:
  enabled: true
  • Add your Sentry DSN to a SENTRY_DSN environment variable.

  • See the Sentry Rack guide for more.

Prometheus

You can enable Prometheus metrics for your API by setting prometheus.enabled in your production settings file.

  • Update the setting in app/settings/production.yml.
prometheus:
  enabled: true

Note: Prometheus metrics should not be exposed publicly! Please ensure you know what you're doing before enabling this feature in your environment.

Docker

Build a production ready image with the Dockerfile and deploy to your favorite platform.

docker build -t grape-api-boilerplate:latest .

Contributing

Contributions are welcome! See CONTRIBUTING.

License

MIT License. See LICENSE for details.

About

A full-featured, production ready, and easy to understand API boilerplate for the Grape framework.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published