Skip to content
No description, website, or topics provided.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config add secrets file Aug 25, 2019
data
helpers add calculate age function and return age Aug 28, 2019
middleware
resources
.gitignore
.prettierrc added prettier config Aug 27, 2019
README.md add sleep del endpoint Aug 30, 2019
index.js
knexfile.js
package.json Bump knex from 0.19.2 to 0.19.5 Oct 28, 2019
server.js WIP: sleep endpoints Aug 28, 2019
yarn.lock

README.md

Sleep Tracker Backend

https://sleeptracker-api.herokuapp.com/

Endpoints

POST /auth/login

Expected Payload:

{
  "email": "pam@gmail.com",
  "password": "password123"
}

Returns:

{
  "id": 1,
  "email": "pam@gmail.com",
  "parent_name": "Pam Beasley",
  "child_name": "Cecelia",
  "age": "1 week",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWJqZWN0IjoxLCJlbWFpbCI6ImFtYW5kYUBhb2wuY29tIiwiaWF0IjoxNTY3MDM4MDg3LCJleHAiOjE1Njc2NDI4ODd9.vNfxryaHCkhsZ1I1jJHmH4iscWxV38FGvEyJEtKPBHI"
}

POST /auth/register

Expected Payload:

{
  "email": "pam@gmail.com",
  "parent_name": "Pam Beasley",
  "child_name": "Cecelia",
  "birthday": 1565413200000,
  "password": "password123"
}

Returns:

{
  "id": 1,
  "parent_name": "Pam Beasley",
  "email": "pam@gmail.com",
  "child_name": "Cecelia",
  "age": "1 week",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWJqZWN0IjoxLCJlbWFpbCI6ImFtYW5kYUBhb2wuY29tIiwiaWF0IjoxNTY3MDQ1NDk1LCJleHAiOjE1Njc2NTAyOTV9.dS6X1D3MAK-YD7Qn2kxVPvvzxKQV-ya7LKznrpchNzY"
}

POST /api/sleep

Expected Payload:

{
  "user_id": 1, // from local storage
  "sleep_start": 1567041409223,
  "sleep_end": 1567073809223
}

PUT /api/sleep/:id

Edits the record matching the params: id

Expected Parameter: The id of the sleep session

Expected Payload:

{
  "sleep_start": 1567041409223,
  "sleep_end": 1567073809223
}

DELETE /api/sleep/:id

Expected Parameter: The id of the sleep session

GET /api/sleep/:userid

Expected Parameter: The user_id from local storage

Returns:

{
  "id": 1,
  "email": "pam@gmail.com",
  "parent_name": "Pam Beasley,
  "child_name": "Cecelia",
  "birthday": "2019-08-21T05:00:00.000Z",
  "password": "$2a$10$e73godn0jIRzGPj.kWYwAueL5jMxOoXRG2vb.cPjl0AYdRcO.Zc0.",
  "data": [
    {
      "id": 1,
      "sleep_start": 1567041409223,
      "sleep_end": 1567073809223,
      "user_id": 1
    },
    {
      "id": 2,
      "sleep_start": 1566951009244,
      "sleep_end": 1566992209228,
      "user_id": 1
    },
    {
      "id": 3,
      "sleep_start": 1566871389223,
      "sleep_end": 1566909409223,
      "user_id": 1
    }
  ]
}
You can’t perform that action at this time.