Template API project with simple token authentication and devise. Every request must be signed with an authentication token header (X-USER-TOKEN).
You can use params instead of headers.
- Clone this repo
- Create your .ruby-version file
- Create your database.yml file
- Run:
bundle install
rake db:create
rake db:migrate
RAILS_ENV=test rake db:migrate
- Start your server
rails s
For code analisys run:
rake code_analysis
You can run your tests using:
rspec
Example requests:
curl -X POST -H "Accept: application/json" -H "Content-Type: application/json"\
http://localhost:3000/api/v1/users/ -d\
'{ "user":
{
"email":"hello@hello.com",
"password":"123456789",
"password_confirmation":"123456789"
}
}'
curl -X POST -H "Accept: application/json" -H "Content-Type: application/json"\
http://localhost:3000/api/v1/users/sign_in -d\
'{ "user":
{
"email":"hello@hello.com",
"password":"123456789"
}
}'
curl -X DELETE -H "X-USER-TOKEN: MTMEGgwVZxUidW2-iMjj" -H "Content-Type: application/json"\
http://localhost:3000/api/v1/users/sign_out
curl -X POST -H "Accept: application/json" -H "Content-Type: application/json"\
http://localhost:3000/api/v1/users/password -d\
'{ "user":
{
"email":"hello@hello.com"
}
}'
curl -X PUT -H "Content-Type: application/json"\
http://localhost:3000/api/v1/users/password -d\
'{ "user":
{
"password":"demiandemian",
"password_confirmation":"demiandemian", "reset_password_token":"1dcce3ffa47fedf0c0fe1d3debba6686982f7e11ff46c43fbcdabd5d7eabadaa"
}
}'
curl -X PUT -H "X-USER-TOKEN: vxKbHC4zQoYZp2ztJjVB" -H "Accept: application/json"\
-H "Content-Type: application/json"\
http://localhost:3000/api/v1/users/3 -d\
'{ "user":
{
"username":"juanito"
}
}'
curl -X POST -H "Accept: application/json" -H "Content-Type: application/json"\
http://localhost:3000/api/v1/users/facebook_login -d\
'{
"type": "facebook",
"fb_access_token":"4CC3355T0K3N"
}'
curl -X PUT -H "X-USER-TOKEN: f84KxyzgwsjDyoJjbwbJ" -H "X-USER-FACEBOOK: id1234"\
-H "Accept: application/json" -H "Content-Type: application/json"\
http://localhost:3000/api/v1/users/3 -d \
'{ "user":
{
"username":"juanito2"
}
}'