use camelCase for vars and files
express, knex, sqlite3, pg, nodemon, dotenv cross-env, cors bcryptjs, jsonwebtoken, jest, supertest
node_modules/
data/
--- migrations/
--- createUsersTable.js
--- createPotlucksTable.js...
--- seeds/
--- 01Users.js
--- 02Potlucks.js...
--- dev.sqlite3
--- testing.sqlite3
--- db.js
models/
--- users.js
--- potlucks.js...
routes/
--- index.js
--- users.js
--- potlucks.js...
controllers/
--- users.js
--- potlucks.js...
middleware/
--- auth.js
server.js
index.js
knexfile.js
.env
Base url: https://bw-potluckplanner.herokuapp.com/
Routes marked with (required) require Authorizaton header set with JWT
Base endpoint; can use to check if its up and running
Returns:
"Welcome to the API"
Logs in user
Accepts:
{
username,
password
}
Returns:
{
token: jwtToken,
message: "Welcome username"
}
Signs up new user
Accepts:
{
email,
username,
password,
location (optional),
pfp (optional)
}
Returns:
{
token: jwtToken,
message: "Your account was created"
}
Gets array of users based on optional search query
*not setting ?username=value
will return all users
Returns:
{
users: [
{
id: user's id,
email: user's email,
username: user's username,
pfp: user's profile pic,
location: user's location
}...
]
}
Gets user info with list of potlucks they've created
Returns:
{
user: {
id: user's id,
username: user's username,
email: user's email,
pfp: user's profile pic,
location: user's location,
potlucks: [
{
potluckId: potluck's id,
title: potluck's title,
organizerId: organizer's id,
when: datetime of when potluck will take place
location: potluck's location
}...
]
}
}
Updates info about a user
Accepts:
{
username (optional),
email (optional),
password (optional),
location (optional),
pfp (optional)
}
Returns:
{
message: "Your account info was updated",
user: {
id
username,
email,
password,
location,
pfp
}
}
Deletes a users account
Returns:
{
message: "Your account was deleted,
user: {
id,
username,
email,
password,
location,
pfp
}
}
Get's an array of all a users potlucks
*users can only get their own potlucks from this endpoint
Returns:
[
{
id,
organizerId,
title,
when,
location
}...
]
Create's a new potluck
Accepts:
{
title,
when,
location,
items: [
"itemName"
...
]
}
Returns:
{
message: "Potluck created",
potluck: {
id,
organizerId,
title,
when,
location,
items: [
{
id,
name,
guestResponsible,
potluckId
}...
]
}
}
Returns info about a single potluck including food items and guests attending
Returns:
{
potluckId,
title,
when,
location,
organizerId,
organizerUsername,
organizerPfp,
organizerLocation,
items: [
name,
potluckId,
guestUsername,
guestId,
guestPfp,
guestLocation
],
guests: [
{
id,
username,
pfp,
location
}
]
}
Updates the potluck with new information
Accepts:
{
title,
when,
location,
items: [
"itemName",
...
]
}
Returns:
{
potluckId,
title,
when,
location,
organizerId,
organizerUsername,
organizerPfp,
organizerLocation,
items: [
{
name,
potluckId,
guestUsername,
guestId,
guestPfp,
guestLocation
}...
],
guests: [
{
id,
username,
pfp,
location
}...
]
}
Deletes a potluck
Returns:
{
message: "Your potluck was deleted",
potluckToDelete: {
id,
organizerId,
title,
when,
location
}
}
Gets all items for a potluck
Returns:
[
{
name,
potluckId
}
]
Gets all items a user plans to bring
Returns: [ { id, name, guestResponsible, potluckId } ]
Adds an item to a potluck
Accepts:
{
name,
}
Returns:
"[item's name] added"
updates a specific potluck item
Accepts:
{
name,
}
Returns:
{
message: "Item updated"
}
Removes a specific item from a potluck
Returns:
{
message: "You have removed this item from the potluck"
}
Gets an array of invitations for a potluck
Returns:
[
{
title,
username,
id
}...
]
Gets all invitations for a user
Returns:
[
{
title,
username,
id
}...
]
Invites a user to a potluck
Accepts:
{
id (the guest's id),
username
}
Returns:
"[guests username] successfully invited"
Route for user to accept or decline an invite
Accepts:
{
status: (-1 for decline, 1 for accept)
}
Returns:
when accepted
{
message: "Congrats - you are on the guestlist"
}
when declined
{
message: "Hope to see you at the next one!"
}
Returns:
{
message: "You have been removed from the guestlist of this potluck"
}
Gets all guests attending a potluck
Returns:
{
title,
username,
potluckId
}
Removes a user from the guest list
Returns:
{
message: "Guest successfully removed from guestlist"
}