keeperofthenecklace / chicago_api

A simple rails api using active_model::serializer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

README

This is a simple lightweight Rails::API project serving JSON resources to a seperate node app “chicago_north”. Chicago_north app is available in my private repository (WIP), is a single page application built on Flux, React.js (view) and Angular.js (model & controller).

The objective here is to slice what would be a monolithic Rails app into a lightweight backend serving API.

Devise is used to authenticate the user in each request.

Adding additional middleware

$ bundle exec rake middleware

Seeding & Running the web application

bundle exec rake db:create:all

bundle exec rake db:migrate

bundle exec rake db:seed

Testing API with Cucumber, Rack-test & Sinatra

From your terminal type:

rackup (starts sinatra on port=9292)
rake cucumber:all

Testing API with Curl

From your terminal type:

$ rails s -p 3002
(starts WEBrick server on port=3002)

curl localhost:3002/v1/login --data "user[email]=test@test.com&user[username]=user&user[password]=password&user[password_confirmation]=password"

You should have a JSON response similar to this:

{
  "email":"test@test.com",
  "token_type":"Love_Is_An_Adventure!",
  "user_id":1,
  "access_token":"1:JzuQ1sXoAPfM_zWpuhNB"
}

About

A simple rails api using active_model::serializer


Languages

Language:Ruby 88.7%Language:HTML 9.1%Language:Gherkin 2.2%