{
username: string, // Required
password: string, // Required
about: text, // Required
points: integer // Required
}
{
title: string, // Required
description: string, // Required
location: string, // Required
upvotes: integer, // Defaults to 0
user_id: integer, // Foreign key required
state_id: integer // Foreign key required
}
{
name: string, // Required
}
Request Type | Endpoint | Description |
---|---|---|
POST | /api/auth/register | Creates User |
POST | /api/auth/login | Creates JWT |
GET | /api/users | Returns All Users |
GET | /api/users/:id | Returns User By ID |
PUT | /api/users/:id | Update User |
DELETE | /api/users/:id | Remove User |
GET | /api/users/:id/states | Returns User states |
GET | /api/users/:id/states/:id | Returns User state by ID |
GET | /api/users/:id/issues | Returns User issues |
GET | /api/users/:id/issues/:id | Returns User issue by ID |
POST | /api/users/:id/states | Add state to user |
DELETE | /api/users/:id/states | Deletes state from user |
Request Type | Endpoint | Description |
---|---|---|
GET | /api/states | Returns all states |
GET | /api/states/:id | Returns state by ID |
GET | /api/states/:id/issues | Returns all state issues |
GET | /api/states/:id/issues/:id | Returns state issue by ID |
POST | /api/states/:id/issues | Create issue for state |
DELETE | /api/states/:id/issues/:id | Remove issue from state |
PUT | /api/states/:id/issues/:id | Updates issue from state |
Request Type | Endpoint | Description |
---|---|---|
GET | /api/issues | Returns all issues |
GET | /api/issues/:id | Returns issue by ID |
Expects the following shape
{
username: string,
password: string
}
Expects the following shape
{
username: string,
password: string
}
- Returns all users in database
[
{
id: 1,
username: "Mario",
points: 0,
about: "I enjoy long walks on the beach."
},
{
id: 2,
username: "Sara",
points: 0,
about: "I travel all around the United States looking for adventure"
},
{
id: 3,
username: "Bob",
points: 0,
about: "I drive my Miata up and down the east coast weekly."
},
]
- Returns user with matching id
{
id: 1,
username: "Mario",
points: 0,
about: "I enjoy long walks on the beach."
}
- Updates user information
- Do not modify password
Expects the following shape :
{
username: string,
points: integer,
about: text
}
- Removes user with matching id
- Returns special message
{
message: "You deleted <username>"
}
- Returns an array of states the user follows
[
{
state: "Alabama",
state_id: 1
},
{
state: "Alaska",
state_id: 2
},
{
state: "Arizona",
state_id: 3
}
]
- Where the second id parameter is the state_id
- Returns a users followed state by id
{
state: "Alabama",
state_id: 1
}
- Adds a state to a users followed states Expects the following shape :
{
state_id: 21
}
- Returns an updated array of states the user follows
[
{
state: "Alabama",
state_id: 1
},
{
state: "Alaska",
state_id: 2
},
{
state: "Arizona",
state_id: 3
},
{
state: "Massachusetts",
state_id: 21
}
]
- Where the second id parameter is the state_id
- Removes the state from a users followed states
- Returns an array of all states
[
{
id: 1,
name: "Alabama"
},
{
id: 2,
name: "Alaska"
},
{
id: 3,
name: "Arizona"
},
]
- Returns state with matching id
{
id: 29,
name: "New Hampshire"
}
- Returns an array of all issues everywhere
[
{
id: 16,
title: "No complaints",
description: "I just came here to just say that the fried chicken at the Puritan Backroom is delicious!",
location: "Manchester",
upvoted: 0,
created_at: "2020-03-03T15:42:35.153Z",
updated_at: "2020-03-03T15:42:35.153Z",
user_id: 3,
state_id: 29
},
{
id: 17,
title: "Bicycles",
description: "There needs to be more bicycle lanes downtown. I am too affraid to ride because cars never give me enough room",
location: "Manchester",
upvotes: 0,
created_at: "2020-03-03T15:42:35.153Z",
updated_at: "2020-03-03T15:42:35.153Z",
user_id: 3,
state_id: 29
},
]
- Returns issue with matching id
{
id: 5,
title: "Dirty Beach",
description: "There is so much litter on the Cape, it's disgraceful!",
location: "Cape Code",
upvotes: 0,
created_at: "2020-03-03T15:42:35.153Z",
updated_at: "2020-03-03T15:42:35.153Z",
user_id: 1,
state_id: 21
}
- Returns an array of all issues for a specified state
[
{
id: 1,
title: "Potholes",
description: "There is a huge pothole on Interstate 95. It blew out my tire!",
location: "Interstate 95 south, mile marker 421",
upvotes: 0,
user_id: 2,
created_at: "2020-03-03T15:42:35.153Z",
updated_at: "2020-03-03T15:42:35.153Z"
},
{
id: 2,
title: "Construction",
description: "There has been construction going on outside my house for weeks. This needs to stop!",
location: "456 Elm street, Winchester",
upvotes: 0,
user_id: 2,
created_at: "2020-03-03T15:42:35.153Z",
updated_at: "2020-03-03T15:42:35.153Z"
},
]
- Returns issue with matching id for a specified state
{
id: 4,
title: "Train issues",
description: "The train going into Boston is filthy. We really need someone to clean it periodically. I once sat on someone's leftover jelly donut. Ruined my new pants",
location: "29 Waterfield Rd, Winchester, MA 01890",
upvotes: 0,
created_at: "2020-03-03T15:42:35.153Z",
updated_at: "2020-03-03T15:42:35.153Z",
user_id: 2,
state_id: 21
}
- Creates new issue for state
- Upvotes (not shown) will automatically be set to 0
- user_id and state_id will be set by back end 😁
Expects the following shape :
{
title: string,
description: string,
location: string,
upvotes: integer
}
Sends back new issue
{
id: 18,
title: "Your new title",
description: "Your new description",
location: "Your new location",
upvotes: 0,
created_at: "2020-03-03T16:16:53.084Z",
updated_at: "2020-03-03T16:16:53.084Z",
user_id: 6,
state_id: 21
}
- Removes issue from state
- Returns special message
- Updates issue with matching id for a specified state
- Update at least one field required
Expects the following shape :
{
title: string,
description: string,
location: string,
upvotes: integer
}
Sends back updated issue
{
id: 18,
title: "Your updated title",
description: "Your updated description",
location: "Your updated location",
upvotes: 0,
created_at: "2020-03-03T16:16:53.084Z",
updated_at: "2020-03-03T16:16:53.084Z",
user_id: 6,
state_id: 21
}