Coder Social home page Coder Social logo

georgiybykov / udatapp Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.28 MB

Ruby on Rails API project to store a data of the users using authentication with JWT, API reversional versioning, rswag integration specs with OpenAPI documentation &.

Ruby 99.70% HTML 0.30%
api dry-rb jwt open-api rails rspec rswag-api rubocop ruby ruby-on-rails

udatapp's Introduction

udatapp

RuboCop RSpec

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

Fetch and start the project:

$ git clone [email protected]: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

Run server:

$ bundle exec bin/rails server

Then visit: http://localhost:3000


Authentication

  • To create a new user:
curl -X POST localhost:3000/api/v2/registration \
     -H 'Content-type: application/json' \
     -d '{ "email": "[email protected]", "password": "123456789" }'
  • To authenticate the user:
curl -X POST localhost:3000/api/v2/login \
     -H 'Content-type: application/json' \
     -d '{ "email": "[email protected]", "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>'

Run tests:

$ bundle exec rspec

Run linter:

$ bundle exec rubocop

Generate rswag API documentation:

$ bundle exec rails rswag:specs:swaggerize

API documentation will be available at:

http://localhost:3000/api-docs/index.html

Examples:

  • API-docs main page:

API-docs main page

  • /note/:id current v2 endpoint:

/note/:id endpoint

  • /note/:id deprecated v1 endpoint:

/note/:id deprecated endpoint


Good luck! May the force be with you!

udatapp's People

Contributors

georgiybykov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.