Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
a3950f2
Setting up GitHub Classroom Feedback
github-classroom[bot] Jul 20, 2022
2846657
set up initial backend files, create and delete scripts
N-LEE-94 Jul 26, 2022
0470741
added express on port 4000
fkit00 Jul 26, 2022
d3d69cd
added populate table script, dummy data and a reset script
fkit00 Jul 26, 2022
b6f8642
adding procfile to help with deployment
N-LEE-94 Jul 26, 2022
e3d6dc9
changed script
N-LEE-94 Jul 26, 2022
741637a
testing spacing in procfile
N-LEE-94 Jul 26, 2022
a37b767
changed start script
N-LEE-94 Jul 26, 2022
ae7593b
fixing deploy issues, port thing
N-LEE-94 Jul 26, 2022
f77d597
made some folders- models and routes
fkit00 Jul 26, 2022
b6995df
did a get
N-LEE-94 Jul 26, 2022
c5511c4
added an async
fkit00 Jul 26, 2022
a863244
Initialised back-end docs.
madisonlowe Jul 26, 2022
30a2403
Merge pull request #2 from SchoolOfCode/initialDocs
madisonlowe Jul 26, 2022
f1e3cb0
Update README.md
madisonlowe Jul 26, 2022
8b381b8
Data.js initialised.
madisonlowe Jul 26, 2022
d6442c5
Added usedAs, updated month.
madisonlowe Jul 26, 2022
8fd4d8d
Added foodType.
madisonlowe Jul 26, 2022
fbac44a
Added family.
madisonlowe Jul 26, 2022
d8ecefe
Updated comments.
madisonlowe Jul 26, 2022
26e2a2a
Merge pull request #3 from SchoolOfCode/dataCreation
fkit00 Jul 27, 2022
e106dfa
Add search by food name
multi-vit Jul 27, 2022
458a73e
Merge pull request #4 from SchoolOfCode/add-search
multi-vit Jul 27, 2022
b2073cb
Uncomment search by item
multi-vit Jul 27, 2022
0a6fffb
Debugging search
multi-vit Jul 27, 2022
b16e117
troubleshooting produce paths
fkit00 Jul 27, 2022
0ab4c18
adding item search
fkit00 Jul 27, 2022
b5d3674
checking version are the same
fkit00 Jul 27, 2022
2441616
Complete search by month
multi-vit Jul 27, 2022
1be05b4
Edited data.
madisonlowe Jul 29, 2022
d31c2f5
Updated notes.
madisonlowe Aug 1, 2022
2fd288a
Merge pull request #5 from SchoolOfCode/dataEdits
madisonlowe Aug 1, 2022
07e65ce
random route and function added
codedresser Aug 1, 2022
585ca80
Debug random function
multi-vit Aug 1, 2022
8d3dca4
Account for random number being the same
multi-vit Aug 1, 2022
7cf1ef8
Account for random number being the same
multi-vit Aug 1, 2022
f3a0e7b
Merge pull request #6 from SchoolOfCode/random-get-request
fkit00 Aug 1, 2022
d58b991
done the jest for the models testing
fkit00 Aug 3, 2022
e80fa78
Add first integration test
multi-vit Aug 3, 2022
c1ceaa9
added supertest to test the app routes
fkit00 Aug 3, 2022
82d099b
Complete integration tests but pool not closing properly
multi-vit Aug 3, 2022
5cf6d90
Merge pull request #7 from SchoolOfCode/testing-branch
N-LEE-94 Aug 4, 2022
baae9a7
Finished random 5 number of results test
N-LEE-94 Aug 4, 2022
28751f6
one test passing for random and one test still failing but closer
codedresser Aug 4, 2022
254030e
completed tests to ensure no duplicates are coming through the random…
N-LEE-94 Aug 4, 2022
64d91b4
completed tests to ensure no duplicates are coming through the random…
N-LEE-94 Aug 4, 2022
1ee2fcf
Add images for august
multi-vit Aug 4, 2022
69723e7
Add samphire
multi-vit Aug 5, 2022
f69692b
Merge pull request #8 from SchoolOfCode/images
multi-vit Aug 5, 2022
7467015
Complete random 5 test working for route and function
codedresser Aug 5, 2022
5c02407
Merge pull request #9 from SchoolOfCode/random-test
multi-vit Aug 5, 2022
4c17abe
Fix image urls due to merge issues
multi-vit Aug 7, 2022
e90c2f7
Updated data for August.
madisonlowe Aug 9, 2022
75649d1
Merge pull request #10 from SchoolOfCode/images
madisonlowe Aug 9, 2022
9a16f44
Removed '.
madisonlowe Aug 9, 2022
8545f0c
Merge pull request #11 from SchoolOfCode/grammaredit
madisonlowe Aug 9, 2022
c541e7f
Edited lamb's lettuce.
madisonlowe Aug 9, 2022
3618ab2
Merge pull request #12 from SchoolOfCode/grammaredit2
madisonlowe Aug 9, 2022
b7bbeab
Strech Goal/ Recipe API
Gdarar Aug 11, 2022
c6d797b
expanded testing strings to give more context and added a small note …
fkit00 Aug 11, 2022
71ff616
Updated README.
madisonlowe Aug 11, 2022
89dd438
Updated PLAN.md.
madisonlowe Aug 11, 2022
27f2156
Merge pull request #13 from SchoolOfCode/operation-code-cleanup-backend
madisonlowe Aug 12, 2022
e23c033
Addressed conflicts.
madisonlowe Aug 14, 2022
9ed2e22
Merge pull request #14 from SchoolOfCode/readmeUpdate
madisonlowe Aug 14, 2022
3714b42
Add allergens route and model
multi-vit Sep 9, 2022
21fa090
Add model and route test for allergens
multi-vit Sep 9, 2022
f517a31
Merge pull request #15 from SchoolOfCode/allergens
fkit00 Sep 9, 2022
7c1c4f8
Added and tested models and routes for more searches.
madisonlowe Sep 9, 2022
fe90096
Merge pull request #16 from SchoolOfCode/clickableLis
fkit00 Sep 9, 2022
a9b2eee
Updating data.js.
madisonlowe Oct 18, 2022
9734402
B-group added to data.js.
madisonlowe Oct 18, 2022
fdabdfc
Added descriptions for data.js.
madisonlowe Oct 18, 2022
970a0b0
Descriptions added to data.js.
madisonlowe Oct 18, 2022
85a3526
Data.js for Nov finished up to L.
madisonlowe Oct 18, 2022
9e5734f
November descriptions added to data.js.
madisonlowe Oct 19, 2022
b161d34
imageURL strings updated.
madisonlowe Oct 19, 2022
79fe227
Descriptions complete.
madisonlowe Oct 19, 2022
469384b
Removed TODO comments.
madisonlowe Oct 19, 2022
c1cab20
Syntax edits.
madisonlowe Oct 19, 2022
636adf2
Updated syntax.
madisonlowe Oct 19, 2022
dbff461
Tidied comments.
madisonlowe Oct 19, 2022
0242064
Updated docs.
madisonlowe Oct 19, 2022
994f225
Quick check of data.js.
madisonlowe Oct 20, 2022
860c7c0
Cherries plurality error.
madisonlowe Oct 20, 2022
2beac4c
Added apostrophe.
madisonlowe Oct 20, 2022
8b06223
Guinea fowl edit.
madisonlowe Oct 20, 2022
d5f365c
Removed space.
madisonlowe Oct 20, 2022
85a9114
Sputnik satellite lore reinstated.
madisonlowe Oct 20, 2022
846026a
Updated changes.
madisonlowe Oct 20, 2022
c428c8b
Merge pull request #17 from SchoolOfCode/apiUpdates
multi-vit Oct 20, 2022
251c74d
Remove unnecessary success boolean from response
multi-vit Nov 27, 2024
7ef38a0
Update tests to no longer expect success boolean
multi-vit Nov 27, 2024
74c38c1
Remove console log
multi-vit Nov 27, 2024
77fc3d8
Make query function async
multi-vit Nov 27, 2024
43c167f
Run npm audit to squash vulnerabilities
multi-vit Nov 27, 2024
79be3bc
Remove procfile as no longer needed for deploy
multi-vit Nov 27, 2024
b16abb9
Update README to reference new deploy locations and correct spelling …
multi-vit Nov 27, 2024
81a9b30
Merge pull request #18 from SchoolOfCode/redeploy-and-tidy
madisonlowe Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.env
node_modules
.DS_Store

192 changes: 190 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,190 @@
[![Open in Visual Studio Code](https://classroom.github.com/assets/open-in-vscode-c66648af7eb3fe8bc4f294546bfd86ef473780cde1dea487d3c4ff354943c9ae.svg)](https://classroom.github.com/online_ide?assignment_repo_id=8143654&assignment_repo_type=AssignmentRepo)
# final-project_back-end
# 12\*\* Seasonality App: Back-End Documentation

This repository holds the back-end documentation for _Seasonal_ by Team 12\*\* (Twelve Exponential). _Seasonal_ is our final project with the [School of Code](https://github.com/SchoolOfCode). In an agile team, over the course of a month, we researched, designed, and built the first iteration of our application, and are currently working on implementing stretch goals.

The core aim of _Seasonal_ is to make it easier and more accessible for users to find out what food is in season in the UK during any given month. Users will be immediately provided with foods currently in season on the landing page, and then can navigate to more food currently in season, or can perform searches for different months, items and recipes to see when they're in season, as well as information on cooking, growing, and ecological impact.

For more details on what we intend on doing next with _Seasonal_, please refer to our project roadmap!

The front-end for this project can be [found in this linked repository](https://github.com/SchoolOfCode/final-project_front-end-12).

Our team consists of:

- Andy Johnson [@multi-vit](https://github.com/multi-vit)
- Fiona Kitchen [@fkit00](https://github.com/fkit00)
- Guiji Darar [@Gdarar](https://github.com/Gdarar)
- Madison Lowe [@madisonlowe](https://github.com/madisonlowe)
- Matthew Miller [@codedresser](https://github.com/codedresser)
- Nathan Lee [@N-LEE-94](https://github.com/N-LEE-94)

If you have any questions, feel free to get in touch! Thanks!

## Installation

To install this repository on your local machine, fork or clone the repository from GitHub. To do this, you can run:

```
git clone https://github.com/SchoolOfCode/final-project_back-end-12.git
```

Or to fork, you can press the 'fork' button on this page, and follow the on-screen instructions.

Once you have access to this repository on your local machine, change directory into the right folder:

```
cd final-project_back-end-12
```

Once you are inside this directory, run:

```
npm i
```

This will install all the necessary dependencies.

We are using ES6 import and export syntax.

## Setting Up Your Environment

After you have installed the project on your local machine, you will want to set up the necessary environment variables to connect the project to the database.

To do this, create a `.env` file at the root level of the folder.

Inside the root level, where 'loremipsum' is a variable representing your own credentials, save the following database credentials inside of the `.env` file:

```
PGURI=loremipsum
```

## Scripts and Commands

To run the back-end on localhost, run:

```
npm start
```

To run our testing suites, run:

```
npm test
```

To reset the database, run:

```
npm run reset
```

For other useful commands and scripts, please refer to `scripts` in the `package.json` file.

## Back-End Structure

We are currently using a relational PostgreSQL database hosted on ~~Cyclic~~ Supabase, and our back-end is built using Node.js and Express, hosted on Lade. For testing the back-end, we are currently using Jest and Supertest.

### Directory Structure

In the back-end repository, our key directories and files are structured as follows:

```
-final-project_back-end-12
- db
- index.js
- data.js
- scripts
- createTable.js
- deleteTable.js
- populateTable.js
- helper_scripts
- randomGet.js
- randomGet.test.js
- testingdata.js
- models
- index.js
- index.test.js
- routes
- index.js
- app.js
- app.test.js
- package.json
- .env
- .gitignore
- README.md
```

## Data Shape

### Produce Table

For the produce table, our data on the back-end is provided to the database as an array of objects.

Each object represents one food entry, and is formatted as thus:

```
{
foodName: string,
imageURL: string,
description: string,
family: string,
foodType: string,
usedAs: string,
month: string[],
allergens: string,
}
```

An example entry:

```
{
name: "Aubergine",
imageURL: "https://auberginepic.com",
description: "This is a description of an aubergine. This will be a longer piece of text. It will describe the following things: what the item is, what value it has nutritionally or if there are any allergens, what to make with it, and how to grow it.",
family: "Nightshade",
foodType: "Berry",
usedAs: "Vegetable",
month: ["January", "February"],
allergens: "None",
}
```

### Data Content Guides

For a description of what each key-value pair inside each data object entry should contain, please see below:

- `name`: The name of the food item.
- `imageURL`: A URL for the image or graphic which represents the item.
- `description`: A description - a few short sentences, according to our description content guide - of the item.
- `family`: The actual family of the item, eg. nightshade, mollusc.
- `usedAs`: How a food is used, eg. tomato and aubergine would be “Vegetable” even though they're technically fruits.
- `month`: The months that the item is in season for.
- `allergens`: Anything that is an allergen in the item.

As a content guide for how the 'description' segment of each object in our `produce` data should be organised, please see the below:

<blockquote>

**_The first part should be a short description of the item._** Aubergines are a dark purple berry - though they’re functionally used as a vegetable - which are at their cheapest and highest quality in the shops from July to September.

**_The second part should mention any allergens or notable nutritional info._** They’re a good source of fibre, and are also low GI, so won’t raise your blood glucose levels. No allergens to aubergine are currently known; they are part of the nightshade family.

**_The third part should mention, broadly, how to cook with it._** You can grill, fry, griddle, barbecue and bake aubergines. They’re often added to dishes like curries and casseroles. Famous dishes using aubergine include ratatouille and moussaka, and they feature widely in Mediterranean cuisine. They have a mellow flavour that combines well with other ingredients.

**_The fourth part should briefly outline ideal growing conditions._** When grown, they like sunny and warm weather, and do best when grown in a greenhouse in the UK climate.

</blockquote>

If any of this information is not available, feel free to substitute as appropriate with more information in one of the other categories, how to pick good examples of the food, or else omit the section entirely. It's up to personal discretion, keeping in mind at all times our goal of making information readable and accessible to users, without passing prescriptive health advice or judgements.

## Roadmap

The stretch goal that we're currently working on is to integrate the recipe arm of our product design. With this stretch goal, users should be able to locate and search for seasonal recipes which match up to different foods in season.

Following meeting this stretch goal, our next goal will be to integrate a maps API, to allow users to search for local farms and growers near them.

## Notes for Team Members

Please refer to Trello for all upcoming tickets related to this repository.

For any needed credentials, contact a member of the team with server and database access.
22 changes: 22 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import express from "express";
import cors from "cors";
import router from "./routes/index.js";

const PORT = process.env.PORT || 4000;

export const app = express();

app.use(cors());
app.use(express.json());

app.use("/produce", router);

app.get("/", (req, res) => {
res.send(
"Go to /produce to get all items, or use ?item= or ?month= to query specifically, or /produce/random if you're feeling lucky."
);
});

app.listen(`${PORT}`);

console.log(`Listening on ${PORT}`);
Loading