This API is designed to accompany the JSynth web browser client. It stores user information including login credentials and effects settings.
From the beginning, I knew this API would be relatively simple. The majority of the work on this project would happen on the front-end. It would be just a users resource and a synth_settings resource.
Being brutally honest with myself, the majority of my difficulties stemmed from being over-confident in my Rails ability. All of my struggles stemmed from rushing a bit too much instead of doing my due dilligence.
This process taught me that I should never be to confident in my abilities and to ALWAYS read the docs.
- Ruby
- Ruby on Rails
- Heroku
I would like to add more columns to my table for more effects.
- Download template, unzip and rename
- bundle install
- Initialize git and heroku repos
- Deploy to heroku
Verb | URI Pattern | Controller#Action |
---|---|---|
POST | /sign-up |
users#signup |
POST | /sign-in |
users#signin |
PATCH | /change-password |
users#changepw |
DELETE | /sign-out |
users#signout |
Request:
curl http://localhost:4741/sign-up \
--include \
--request POST \
--header "Content-Type: application/json" \
--data '{
"credentials": {
"email": "'"${EMAIL}"'",
"password": "'"${PASSWORD}"'",
"password_confirmation": "'"${PASSWORD}"'"
}
}'
[email protected] PASSWORD=hannah curl-scripts/auth/sign-up.sh
Response:
HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8
{
"user": {
"id": 1,
"email": "[email protected]"
}
}
Request:
curl http://localhost:4741/sign-in \
--include \
--request POST \
--header "Content-Type: application/json" \
--data '{
"credentials": {
"email": "'"${EMAIL}"'",
"password": "'"${PASSWORD}"'"
}
}'
[email protected] PASSWORD=hannah curl-scripts/auth/sign-in.sh
Response:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"user": {
"id": 1,
"email": "[email protected]",
"token": "BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f"
}
}
Request:
curl --include --request PATCH "http://localhost:4741/change-password" \
--header "Authorization: Token token=$TOKEN" \
--header "Content-Type: application/json" \
--data '{
"passwords": {
"old": "'"${OLDPW}"'",
"new": "'"${NEWPW}"'"
}
}'
OLDPW='hannah' NEWPW='elle' TOKEN='BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f' sh curl-scripts/auth/change-password.sh
Response:
HTTP/1.1 204 No Content
Request:
curl http://localhost:4741/sign-out \
--include \
--request DELETE \
--header "Authorization: Token token=$TOKEN"
TOKEN='BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f' sh curl-scripts/auth/sign-out.sh
Response:
HTTP/1.1 204 No Content
Verb | URI Pattern | Controller#Action |
---|---|---|
GET | /users |
users#index |
GET | /users/1 |
users#show |
PATCH | /users/1 |
users#update |
Request:
curl http://localhost:4741/users \
--include \
--request GET \
--header "Authorization: Token token=$TOKEN"
TOKEN=BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f curl-scripts/users.sh
Response:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"users": [
{
"id": 2,
"email": "[email protected]"
},
{
"id": 1,
"email": "[email protected]"
}
]
}
Request:
curl --include --request GET http://localhost:4741/users/$ID \
--header "Authorization: Token token=$TOKEN"
ID=2 TOKEN=BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f curl-scripts/user.sh
Response:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{
"user": {
"id": 2,
"email": "[email protected]"
}
}
Request:
curl "http://localhost:4741/users/${ID}" \
--include \
--request PATCH \
--header "Authorization: Token token=${TOKEN}" \
--header "Content-Type: application/json" \
--data '{
"user": {
"email": "'"${EMAIL}"'"
}
}'
ID=1 TOKEN="BAhJIiU1NGNlYjRmMjBhM2NkZTZiNzk1MGNiYmZiYWMyY2U4MwY6BkVG--ddb1e16af0e05921aa56d771e4a2f816f2a1d46e"
EMAIL=mike@m
sh curl-scripts/users/user-update.sh
Response:
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{"user":{"id":1,"email":"mike@m"}}
Verb | URI Pattern | Controller#Action |
---|---|---|
POST | /synth_settings |
synth_settings#create |
GET | /synth_settings |
synth_settings#index |
PATCH | /synth_settings/:id |
synth_settings#update |
DELETE | /synth_settings/:id |
synth_settings#destroy |
Request:
curl "http://localhost:4741/synth_settings" \
--include \
--request POST \
--header "Content-Type: application/json" \
--header "Authorization: Token token=${TOKEN}" \
--data '{
"synth_setting": {
"name": "'"${NAME}"'",
"oscillator_type": "'"${TYPE}"'",
"chorusrate": "'"${CHORUSRATE}"'",
"chorustoggle": "'"${CHORUSTOGGLE}"'",
"filtercutoff": "'"${FILTERCUTOFF}"'",
"filtertoggle": "'"${FILTERTOGGLE}"'"
}
}'
TOKEN='BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f' NAME=Setting TYPE=sine CHORUSRATE=4 CHORUSTOGGLE=true FILTERCUTOFF=1000 FILTERTOGGLE=true sh curl-scripts/synth/create-synth.sh
Response:
HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8
{
"synth_setting": {
"name": "Setting",
"oscillator_type": "sine",
"chorusrate": "4",
"chorustoggle": "true",
"filtercutoff": "1000",
"filtertoggle": "true"
}
}
}
Request:
curl "http://localhost:4741/synth_settings/${ID}" \
--include \
--request PATCH \
--header "Content-Type: application/json" \
--header "Authorization: Token token=${TOKEN}" \
--data '{
"synth_setting": {
"name": "'"${NAME}"'",
"type": "'"${TYPE}"'",
"chorusrate": "'"${CHORUSRATE}"'",
"chorustoggle": "'"${CHORUSTOGGLE}"'",
"filtercutoff": "'"${FILTERCUTOFF}"'",
"filtertoggle": "'"${FILTERTOGGLE}"'"
}
}'
TOKEN='BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f' ID=1 NAME=Setting TYPE=sine CHORUSRATE=4 CHORUSTOGGLE=true FILTERCUTOFF=1000 FILTERTOGGLE=true sh curl-scripts/synth/create-synth.sh
Response:
HTTP/1.1 204 No Content
Request:
curl "http://localhost:4741/synth_settings/${ID}" \
--include \
--request DELETE \
--header "Content-Type: application/json" \
--header "Authorization: Token token=${TOKEN}" \
TOKEN='BAhJIiVlZDIwZTMzMzQzODg5NTBmYjZlNjRlZDZlNzYxYzU2ZAY6BkVG--7e7f77f974edcf5e4887b56918f34cd9fe293b9f' ID=1 sh curl-scripts/auth/sign-out.sh
Response:
HTTP/1.1 204 No Content