https://github.com/phawk/sinatra-api
Simple starting point for making REST APIs in sinatra
https://github.com/phawk/sinatra-api
Last synced: 12 months ago
JSON representation
Simple starting point for making REST APIs in sinatra
- Host: GitHub
- URL: https://github.com/phawk/sinatra-api
- Owner: phawk
- Created: 2014-05-25T10:47:15.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2019-05-06T13:22:38.000Z (almost 7 years ago)
- Last Synced: 2024-10-25T01:39:13.634Z (over 1 year ago)
- Language: JavaScript
- Size: 1.22 MB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sinatra API
A starting point for creating REST APIs in sinatra.
[](https://travis-ci.org/phawk/sinatra-api)
## Includes
* Sinatra + sinatra contrib
* ActiveRecord (default: postgres)
* Warden with basic JWT token auth
* Mail (default delivery: postmark)
* sidekiq for background jobs
* RSpec, rack-test, factory_bot and faker
## Getting started
### Configuration
```sh
# Copy the configuration environment variables
$ cp .env.example .env
# Edit the env vars
$ vim .env
# Create dev + test databases
$ bin/rake db:create
# Run initial migrations
$ bin/rake db:migrate
$ bin/rake db:migrate APP_ENV=test
# Create new migration
$ bin/rake db:create_migration NAME=create_competitions
```
### Running
```sh
$ bin/shotgun
$ open http://localhost:9393
```
### Testing
```sh
$ APP_ENV=test bin/rake db:fixtures:load # run this when making changes to fixtures
$ bin/rspec
```
#### Setup git hooks
```sh
$ echo "bin/rake ci:all" > .git/hooks/pre-push && chmod +x .git/hooks/pre-push
$ echo "bin/rubocop" > .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit
```
#### Docs on test frameworks
* [RSpec expectations](https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers)
* [Mail::TestMailer](https://github.com/mikel/mail#using-mail-with-testing-or-specing-libraries)
### Console
```sh
$ bin/console
```