A standalone Rails/PostgreSQL back-end server which:
Serves JSON music data to my front-end music web application Zing Lite - live - github
Has a full User Authentication cycle with proper secured password (via BCrypt); selective CORS management; Rails' session token stored in database, and CSRF Token served to front-end
Features:
Test-driven-development, models and controller tests with RSpec:
RSpec.describeUser,type: :modeldodescribe'password encryption'doit'does not save passwords to the database'doUser.create!(username: 'chuck_norris',password: 'password')user=User.find_by_username('chuck_norris')expect(user.password).not_tobe('password')endit'encrypts the password using BCrypt'doexpect(BCrypt::Password).toreceive(:create)User.new(username: 'chuck_norris',password: 'password')endend# ...end
RSpec.describe'Songs API',type: :requestdodescribe'GET #index'dobefore(:each)do# ...get'/api/songs/'endit'responses with status code of 200'doexpect(response).tohave_http_status(200)endit'fetches songs with corresponding artists and albums'doexpect(response.body).tomatch_response_schema('all_songs')end# ...endend
Avoid N + 1 queries while fectching complicated JSON data for front-end