# Cookvid - 19
- Our project: A web app that allows you to keep track of your favourite recipes through postgreSQL databases.

---

---
## Miro & Project board

- ☝️ Our initial ideas
---
- Because our miro planning was really detailed we didnt layout much on the project board

---
## Workflow
### Day 1
- Miro brainstorming - UI

---
- Miro brainstorming - User story

---
#### What else did we do on day 1?
- Server initialisation
- Database initialisation
---
Our Schema
```SQL
CREATE TABLE recipes
(
id SERIAL PRIMARY KEY,
recipeTitle VARCHAR(255),
type VARCHAR(255),
ingredients VARCHAR(255),
method TEXT,
vegetarian BOOLEAN
);
```
---
- Handlers
```JavaScript
if (url === "/") {
handlers.homeHandler(request, response);
} else if (url === "/form") {
handlers.formHandler(request, response);
} else if (url === "/submit" || request.method === "POST") {
handlers.submit(request, response);
} else if (
url === "/breakfast" ||
url === "/lunch" ||
url === "/dinner" ||
url === "/dessert" ||
url === "/snacks"
)
```
- Initial testing
- Troubleshooting
---
### Day 2
- TDD for creating new entries to our recipes table *Value Clause*
- Further development on functionality
- CSS
---
## Personal learning objectives
### Lizzy
- Get to grips with Node and feel more confident working with servers
- Testing
- Understand how templates work to serve HTML server-side
---
### Chloe
- Server -> router -> handlers -> database -> model -> templates === ????
- Node templates

---
### Hettie
- Servers + handlers
- Databases
- TDD

---
### James

- Actually doing TDD instead of writing tests after functions have already been written
---
## What went well?

---
- Querying the database and extracting data from it
- Teamwork!
- Ensuring everyone got to work on databases
- Pair swapping
- TDD
- Servers and serving different routes
- Refactoring our code
---
```javascript=
test('Can create new recipe!', t => {
build().then(() => {
const data = {
recipeTitle: 'Spaghetti Bolognese',
type: 'dinner',
ingredients: 'spaghetti, mince, tomato',
method: 'Cook',
vegetarian: false,
}
createNewEntry(data)
.then(() => {
const title = 'Spaghetti Bolognese'
getOneEntry(title).then(entry => {
t.equal(entry.ingredients, 'spaghetti, mince, tomato'),
t.equal(entry.method, 'Cook'),
t.end()
})
})
.catch(err => {
t.error(err), t.end()
})
})
})
```
---
```javascript=
function createNewEntry(data) {
const values = [
data.recipeTitle,
data.type,
data.ingredients,
data.method,
data.vegetarian,
]
return db.query(
`INSERT INTO recipes(recipeTitle, type, ingredients, method, vegetarian) VALUES($1, $2, $3, $4, $5)`,
values,
)
}
```
---
## What didn't go so well?

---
- Heroku
- It went well at first, we managed to deploy our site
BUT
- dependencies and devDependencies are **IMPORTANT**
---
## Questions?
https://cookvid-19.herokuapp.com/

---
## Stop
- multiple people typing at one time
## Go
- 20 / 20 / 20
- Comfortability leaving code halfway through
- Have a clear idea of who is the driver when pairprogramming
## Continue
- Continue sharing knowledge with others
- Explaining things when writing code in pairs
- Checking in and asking the other pair for help
- Switching machines midway through a session
{"metaMigratedAt":"2023-06-15T06:01:28.758Z","metaMigratedFrom":"Content","title":"Cookvid - 19","breaks":true,"contributors":"[{\"id\":\"84d28a23-6942-43f3-a6ba-6835bb139040\",\"add\":728,\"del\":183},{\"id\":\"d6770ca5-656a-4c65-88b8-79b5f1ad5de1\",\"add\":1744,\"del\":533},{\"id\":\"bd6764bd-ae37-4f90-bb83-98f8266bf1dd\",\"add\":1952,\"del\":173},{\"id\":\"6898df79-5b31-4c78-acd1-86a97123cdc1\",\"add\":902,\"del\":131}]"}