Deployed Backend: https://potluck-planner-backend.herokuapp.com
Potluck Event Planner is a full-stack web application that was built during a "build week" by Lambda School students. Each student fulfills a role in the project to collectively build the application.
Potluck Event Planner provides a web application that allows a user to create events in their profile as well as add various details about the potluck. Once a user adds a potluck, they are able to invite other users to attend their event and food items for the potluck. The application could be used for any type of event and is not limited to just potluck events.
- Node.js - JavaScript runtime for executing JavaScript at the server outside the browser
- Express.js - Lightweight web framework to bootstrap Node.js APIs
- SQLite3 - Super lightweight database to bootstrap development environments
- PostgreSQL - An advanced object-relational database for production environments
- Knex.js - A SQL query builder that helps abstracting migrations and DDLs for different database types into a single coherent structure
- Bcrypt.js - A module to help make passwords more secure
- CORS - A Node.js package for providing a Connect/Express middleware that can be used to enable CORS with various options
- Helmet - A collection of 14 smaller middleware functions that set HTTP response headers
- JWT - JSON Web Token for authorization and client side tokens for security
- Supertest - A test module for HTTP assertions
- Jest - A simple JavaScript testing framework
- Dotenv - a zero-dependency module that loads environment variables from a .env file into process.env
A JWT protected endpoint means that a header object, which contains a key called Authorization with the value being a JSON web token, must be passed along with the API call in order to gain access to the endpoint.
{
headers: {
Authorization:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InVzZXIiLCJpZCI6MTksImlhdCI6MTU3NDIwMDM0MiwiZXhwIjoxNTc0Mjg2NzQyfQ.mDNl24-TXWc9xmvWUbOo7CWs8otGTeJkOl9oHqCUUNU",
}
}https://potluck-planner-backend.herokuapp.com/
- JWT protected (header) ❌
- payload (body) ❌
API Running Response (200 OK):
{
"message": "Server up and running!"
}https://potluck-planner-backend.herokuapp.com/api/register
- JWT protected (header) ❌
- payload (body) ✔️
- USER gets validated over requiresAuth middleware
Example Request Body:
{
"username": "user", // required
"password": "password", // required
"firstName": "test", // required
"lastName": "test" // required
}Register a User Response (201 CREATED):
{
"id": 19,
"message": "Welcome user!",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InVzZXIiLCJpZCI6MTksImlhdCI6MTU3NDIwMDM0MiwiZXhwIjoxNTc0Mjg2NzQyfQ.mDNl24-TXWc9xmvWUbOo7CWs8otGTeJkOl9oHqCUUNU"
}Server Error Response (500 SERVER ERROR):
{
"message": "Error occurred while registering a user.",
"error": error
}https://potluck-planner-backend.herokuapp.com/api/login
- JWT protected (header) ❌
- payload (body) ✔️
Example Request Body:
{
"username": "user", // required
"password": "password", // required
}Login a User Response (200 OK):
{
"id": 19,
"message": "Welcome user!",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InVzZXIiLCJpZCI6MTksImlhdCI6MTU3NDIwMDM0MiwiZXhwIjoxNTc0Mjg2NzQyfQ.mDNl24-TXWc9xmvWUbOo7CWs8otGTeJkOl9oHqCUUNU"
}Unauthorized Response (401 UNAUTHORIZED):
{
"message": "Invalid credentials."
}Server Error Response (500 SERVER ERROR):
{
"message": "Error occurred while logging in a user.",
"error": error
}https://potluck-planner-backend.herokuapp.com/potlucks/:id
- JWT protected (header) ✔️
- payload (body) ❌
- ID is defined over the used route at the end
- Authorization gets validated over restricted middleware
- POTLUCK ID gets validated over validatePotluckData middleware
Get Event By Id Response (200 OK):
{
"firstName": "Harry",
"lastName": "Potter",
"name": "potluck1",
"location": "home",
"time": "06:10:00",
"date": "2019-11-25T00:00:00.000Z",
"guests": [
{
"id": 3,
"firstName": "Albus",
"lastName": "Dumbledore",
"accepted": true
},
{
"id": 5,
"firstName": "Ginny",
"lastName": "Weasley",
"accepted": false
}
]
}Server Error Response (500 SERVER ERROR):
{
"message": "DB error. Try again.",
"err": err
}Event Not Found Response (500 SERVER ERROR):
{
"message": `There was an error in getting data from the database.`,
"err": err
}Get all the potlucks organized by a user
https://potluck-planner-backend.herokuapp.com/users/organized
Response - An array of all the potlucks organized by a particular user
Get all the potlucks a user is attending as a guest - GET
https://potluck-planner-backend.herokuapp.com/users/attending?isAttending=true
Query string isAttending to be provided with a value true
Response - An array of all the putlucks a user is attending
Get all potlucks for which the user has not yet responded to invitations
https://potluck-planner-backend.herokuapp.com/users/attending?isAttending=false
Query string isAttending to be provided with a value false
https://potluck-planner-backend.herokuapp.com/potlucks
- JWT protected (header) ❌
- payload (body) ✔️
Example Request Body:
{
"name": "Friendsgiving", // required
"location": "password", // required
"date": "11/23/2019", // required (mm/dd/yy)
"time": "5pm" // required
}Add a Potluck Response (201 OK):
{
"id": 1,
"user_id": "19",
"name": "Friendsgiving",
"location": "2121 Maple St, Cameron Park CA",
"date": "11/23/2019",
"time": "5pm"
}Server Error Response (500 SERVER ERROR):
{
"message": "The potluck could not be created.",
"error": error
}https://potluck-planner-backend.herokuapp.com/potlucks/:id
- JWT protected (header) ✔️
- payload (body) ✔️
- ID is defined over the used route at the end
- Authorization gets validated over restricted middleware
- POTLUCK gets validated over validatePotluckData middleware
Example Request Body:
{
"name": "Friendsgiving", // required
"location": "2121 Maple St, Cameron Park CA", // required
"date": "11/23/2019", // required (mm/dd/yy)
"time": "6pm" // required
}Updating an Event Response (201 CREATED):
{
"id": 1,
"user_id": "19",
"name": "Friendsgiving",
"location": "2121 Maple St, Cameron Park CA",
"date": "11/23/2019",
"time": "6pm"
}Server Error Response (500 SERVER ERROR):
{
"message": "The potluck could not be updated",
"err": err
}https://potluck-planner-backend.herokuapp.com/potlucks/:id
- JWT protected (header) ✔️
- payload (body) ❌
- ID is defined over the used route at the end
- Authorization gets validated over restricted middleware
- POTLUCK ID gets validated over validatePotluckData middleware
Delete Potluck By Id Response (200 OK):
{
message: `The potluck was deleted.`,
}Server Error Response (500 SERVER ERROR):
{
"message": "The potluck could not be deleted'",
"err": err
}https://potluck-planner-backend.herokuapp.com/food
- JWT protected (header) ✔️
- payload (body) ❌
- Authorization gets validated over restricted middleware
Get All Food Items Response (200 OK):
[
{
"food_id": 1,
"name": "Apple Pie"
},
{
"food_id": 2,
"name": "Mashed Potatoes"
},
{
"food_id": 3,
"name": "Chicken"
},
];Server Error Response (500 SERVER ERROR):
{
"message": "'There was an error in getting food from the database.'",
"err": err
}https://potluck-planner-backend.herokuapp.com/food/:id
- JWT protected (header) ✔️
- payload (body) ❌
- ID is defined over the used route at the end
- Authorization gets validated over restricted middleware
Get Food Item By Id Response (200 OK):
{
"id": 1,
"name": "Mashed Potatoes"
},Server Error Response (500 SERVER ERROR):
{
"message": "Error while retrieving food by id from database.",
"err": err
}https://potluck-planner-backend.herokuapp.com/food
- JWT protected (header) ✔️
- payload (body) ✔️
- FOOD gets validated over validateFoodData middleware
- food name must be unique
Example Request Body:
{
"name": "Green Beans"
},Adding a Food Item Response (201 CREATED):
{
{
"id": 10,
"name": "Green Beans"
}
},Server Error Response (500 SERVER ERROR):
{
"message": "Error occured while adding food item.",
"err": err
}https://potluck-planner-backend.herokuapp.com/food/user/:id
- JWT protected (header) ✔️
- payload (body) ❌
- user ID is defined over the used route at the end
- Authorization gets validated over restricted middleware
Get All User Food Items Response (200 OK):
[
{
"name": "Mashed Potatoes"
},
{
"name": "Green Beans"
},
{
"name": "Apple Pie"
},
];Server Error Response (500 SERVER ERROR):
{
"message": "Error while retrieving users food items from database.",
"err": err
}https://potluck-planner-backend.herokuapp.com/food/user/1
- JWT protected (header) ✔️
- payload (body) ✔️
Example Request Body:
{
"food_id": 1,
"potluck_id": 1
},Adding a User Food Response (201 CREATED):
{
"id": 1,
"user_id": 11,
"potluck_id": 1,
"food_id": 1
},Server Error Response (500 SERVER ERROR):
{
"message": "Error while adding user food",
"err": err
}https://corporate-event-planner-be.herokuapp.com/api/vendors/:id
- JWT protected (header) ✔️
- payload (body) ❌
- food ID is defined over the used route at the end
- Authorization gets validated over restricted middleware
Delete Vendor By Id Response (200 OK):
{
message: "This food item was deleted from user.",
}Server Error Response (500 SERVER ERROR):
{
"message": "Error occurred while deleting user food item.",
"err": err
}Role: Backend Developer