khan-ngo / survey-express-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

General Assembly Logo

Surveys Express API - Project 3

Description

Our team project was to build a survey appliction. Ours app is very basic one where each survey has only 1 question. A user must be signed in before they can create/view/modify their surveys. Once the survey has been created, a generated url is created that can be used by anyone to take the survey. All responses for a survey can be viewed by the survey owner.

Links

Front-End

Front-End Deployed: https://kqngo.github.io/survey-client/ Front-End Repo: https://github.com/kqngo/survey-client

Back-End

Back-end Deployed: https://survey-team-project.herokuapp.com/ Back-End Repo: https://github.com/kqngo/survey-express-api

API

Authentication

Verb URI Pattern Controller#Action
POST /sign-up users#signup
POST /sign-in users#signin
PATCH /change-password/:id users#changepw
DELETE /sign-out/:id users#signout

POST /sign-up

Request:

curl http://localhost:4741/sign-up \
  --include \
  --request POST \
  --header "Content-Type: application/json" \
  --data '{
    "credentials": {
      "email": "'"${EMAIL}"'",
      "password": "'"${PASSWORD}"'",
      "password_confirmation": "'"${PASSWORD}"'"
    }
  }'

POST /sign-in

Request:

curl http://localhost:4741/sign-in \
  --include \
  --request POST \
  --header "Content-Type: application/json" \
  --data '{
    "credentials": {
      "email": "'"${EMAIL}"'",
      "password": "'"${PASSWORD}"'"
    }
  }'

PATCH /change-password/:id

Request:

curl --include --request PATCH "http://localhost:4741/change-password/$ID" \
  --header "Authorization: Token token=$TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "passwords": {
      "old": "'"${OLDPW}"'",
      "new": "'"${NEWPW}"'"
    }
  }'

DELETE /sign-out/:id

Request:

curl http://localhost:4741/sign-out/$ID \
  --include \
  --request DELETE \
  --header "Authorization: Token token=$TOKEN"

Surveys

Verb URI Pattern Controller#Action
GET /surveys/:id surveys#show
GET /surveys surveys#index
POST /surveys surveys#create
PATCH /surveys/:id surveys#update
DELETE /surveys/:id surveys#destroy

GET /surveys

Request:

curl "${API}${URL_PATH}/${ID}" \
  --include \
  --request GET \
  --header "Authorization: Token token=$TOKEN"
curl "${API}${URL_PATH}" \
  --include \
  --request GET \
  --header "Authorization: Token token=$TOKEN"

POST /surveys

Request:

curl "${API}${URL_PATH}" \
  --include \
  --request POST \
  --header "Content-Type: application/json" \
  --header "Authorization: Token token=${TOKEN}" \
  --data '{
    "survey": {
      "title": "'"${TITLE}"'",
      "question": "'"${QUESTION}"'"
    }
  }'

PATCH /surveys/:id

Request:

curl "${API}${URL_PATH}/${ID}" \
  --include \
  --request PATCH \
  --header "Content-Type: application/json" \
  --header "Authorization: Token token=${TOKEN}" \
  --data '{
    "survey": {
      "title": "'"${TITLE}"'",
      "question": "'"${QUESTION}"'"
    }
  }'

DELETE /surveys/:id

Request:

curl "${API}${URL_PATH}/${ID}" \
  --include \
  --request DELETE \
  --header "Authorization: Token token=${TOKEN}"

Responses

Verb URI Pattern Controller#Action
GET /responses responses#index
POST /responses responses#create
DELETE /responses/:id responses#destroy

GET /responses

Request:

curl "${API}${URL_PATH}" \
  --include \
  --request GET \
  --header "Content-Type: application/json" \
  --header "Authorization: Token token=$TOKEN" \
  --data '{
      "survey_id": "'"${SURVEYID}"'"
  }'

POST /responses

Request:

curl "${API}${URL_PATH}" \
  --include \
  --request POST \
  --header "Content-Type: application/json" \
  --data '{
    "response": {
      "text": "'"${TEXT}"'",
      "survey_id": "'"${SURVEYID}"'"
    }
  }'

DELETE /responses/:id

Request:

curl "${API}${URL_PATH}/${ID}" \
  --include \
  --request DELETE \
  --header "Content-Type: application/json" \
  --header "Authorization: Token token=$TOKEN" \
  --data '{
      "survey_id": "'"${SURVEYID}"'"
    }'
  1. All content is licensed under a CC­BY­NC­SA 4.0 license.
  2. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact legal@ga.co.

About

License:Other


Languages

Language:JavaScript 83.2%Language:Shell 16.8%