Ruby on Rails API project to store a data of the users.
The project includes and consists of:
- Ruby 2.7.5
- Ruby on Rails 6.1.5
- RSpec as framework for tests
rswag
for integration specs and generated API documentation by OpenAPI Specification- Custom authentication with JWT
- API reversional versioning
dry-rb
stack
$ git clone git@github.com:georgiybykov/udatapp.git
$ cd qna
# Install dependencies:
$ bundle install
$ cp config/database.yml.sample config/database.yml
$ bundle exec bin/rails db:create
$ bundle exec bin/rails db:migrate
$ bundle exec bin/rails server
Then visit: http://localhost:3000
- To create a new user:
curl -X POST localhost:3000/api/v2/registration \
-H 'Content-type: application/json' \
-d '{ "email": "udatapp@email.com", "password": "123456789" }'
- To authenticate the user:
curl -X POST localhost:3000/api/v2/login \
-H 'Content-type: application/json' \
-d '{ "email": "udatapp@email.com", "password": "123456789" }'
On successful login will be returned:
{
"access_token": <token>,
"expires_at": <datetime>
}
The token will be expired after 24 hours by default.
You should use this token for further requests in Authorization
header, for example:
curl -X GET localhost:3000/api/v2/notes \
-H 'Content-type: application/json' \
-H 'Authorization: <token>'
$ bundle exec rspec
$ bundle exec rubocop
$ bundle exec rails rswag:specs:swaggerize
http://localhost:3000/api-docs/index.html
- API-docs main page:
/note/:id
current v2 endpoint:
/note/:id
deprecated v1 endpoint: