From 686d57dbba036c2a08d87ab9049dadd6fae4615b Mon Sep 17 00:00:00 2001 From: Faith Date: Wed, 17 Jan 2024 19:28:58 -0500 Subject: [PATCH 1/4] made initial changes (need to resolve assignment errors) --- api/src/pin/pin.dto.ts | 11 +++++++++++ api/src/prisma/schema.prisma | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/api/src/pin/pin.dto.ts b/api/src/pin/pin.dto.ts index ed6eec3..937b8f7 100644 --- a/api/src/pin/pin.dto.ts +++ b/api/src/pin/pin.dto.ts @@ -16,4 +16,15 @@ export interface PinDto { coordinateY: number; isValid?: boolean; createdAt: Date; + category: string; + reactions: Reaction[]; } + +enum Reaction { + LIKE, + DISLIKE, + SUSTAINABLE, + STORE_UNAVAILABLE, + GOOD_VALUE, + BAD_VALUE +} \ No newline at end of file diff --git a/api/src/prisma/schema.prisma b/api/src/prisma/schema.prisma index 0ab0a30..b002e09 100644 --- a/api/src/prisma/schema.prisma +++ b/api/src/prisma/schema.prisma @@ -18,4 +18,15 @@ model Pin { coordinateY Float isValid Boolean @default(true) createdAt DateTime @default(now()) + category String + reactions Reaction[] } + +enum Reaction { + LIKE + DISLIKE + SUSTAINABLE + STORE_UNAVAILABLE + GOOD_VALUE + BAD_VALUE +} \ No newline at end of file From b1bd572a4c222d5b41fad38218b2931944e384f3 Mon Sep 17 00:00:00 2001 From: Faith Date: Wed, 31 Jan 2024 19:08:51 -0500 Subject: [PATCH 2/4] changed reactions to string (instead of enum) --- api/src/pin/pin.dto.ts | 11 +-------- api/src/prisma/app.db-journal | Bin 12824 -> 12824 bytes .../20231018232930_added_pin/migration.sql | 10 -------- .../migration.sql | 22 ------------------ .../20240131234713_initial_pin/migration.sql | 17 ++++++++++++++ .../migration.sql | 12 ++++++++++ api/src/prisma/migrations/migration_lock.toml | 2 +- api/src/prisma/schema.prisma | 19 ++++----------- 8 files changed, 36 insertions(+), 57 deletions(-) delete mode 100644 api/src/prisma/migrations/20231018232930_added_pin/migration.sql delete mode 100644 api/src/prisma/migrations/20231116001224_fix_misspelling_of_is_valid/migration.sql create mode 100644 api/src/prisma/migrations/20240131234713_initial_pin/migration.sql create mode 100644 api/src/prisma/migrations/20240131235715_convert_reactions_to_string/migration.sql diff --git a/api/src/pin/pin.dto.ts b/api/src/pin/pin.dto.ts index 937b8f7..16cba46 100644 --- a/api/src/pin/pin.dto.ts +++ b/api/src/pin/pin.dto.ts @@ -17,14 +17,5 @@ export interface PinDto { isValid?: boolean; createdAt: Date; category: string; - reactions: Reaction[]; -} - -enum Reaction { - LIKE, - DISLIKE, - SUSTAINABLE, - STORE_UNAVAILABLE, - GOOD_VALUE, - BAD_VALUE + reactions?: string[]; } \ No newline at end of file diff --git a/api/src/prisma/app.db-journal b/api/src/prisma/app.db-journal index 8116ae2a0565a89da892cd4e7442ba25837e4260..f81be46839e20f6fb4af4db65aa844c7098315ac 100644 GIT binary patch delta 433 zcmW-cy=zoK6vgN5vf*tY``iU9K{oh>n30*eZ@wUYAle9GAXqkZ7a85#U@N}KbyJluij3t zc9vj0w**6HjEX8!FKb6j0Hj{Tl3FQ+MhPbBF#mhu{z^8xTYvjFzc;+4mhSy@l>KkH zvupt!OD@wq%cG|y0#GBJpy<5fhFb;^=5K}%uFvSnByj>~+$2s5ta69}tLIId9i?>V z$L62&MLzmnTloGsQzUkZ97%gN0vdEW1B iPntT6U5n%GU36Q`;h|d}|2mz$PVKjkK5Rbu`S~BDU3!K9 delta 264 zcmbP{G9zUJ2NMSq-zf(EY`#;Q6@~Wk88*r>afLSWG9)rEuyUrRrkJH#7#ZjqC7Pz{ znwXiI>RO~&Ch8icBwHq@m|G;88W>FeDc~^KUQpYt`)b9BmyJSCYDLbK<#EGx~Z0iCaFngDJcd9hLaZvI;pwJ=kGBxFfukYFtji-HnKD} zh)+yONll3_$joEx2FmVM7b}^%nM3F!zbX^6G-qCFd3-=-9s>gd2Pcr`$y}}lWV7%B z2}b^V4E* Date: Wed, 7 Feb 2024 19:38:20 -0500 Subject: [PATCH 3/4] feat: dockerize --- api/dockerfile | 13 +++++++++++++ api/package.json | 1 - compose.yml | 28 ++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 api/dockerfile create mode 100644 compose.yml diff --git a/api/dockerfile b/api/dockerfile new file mode 100644 index 0000000..589aa17 --- /dev/null +++ b/api/dockerfile @@ -0,0 +1,13 @@ +FROM node:lts + +RUN mkdir -p /app/ + +COPY . /app/ + +WORKDIR /app/ + +EXPOSE 3000 + +RUN npm install + +CMD ["npm", "run", "debug:watch"] \ No newline at end of file diff --git a/api/package.json b/api/package.json index 0f69763..f6c3c6d 100644 --- a/api/package.json +++ b/api/package.json @@ -5,7 +5,6 @@ "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "prepare": "husky install", "lint": "eslint --ignore-path .gitignore --ext .ts src", "lint:fix": "npm run lint -- --fix", "format": "prettier write src", diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..f1d9424 --- /dev/null +++ b/compose.yml @@ -0,0 +1,28 @@ +version: "3.8" + +services: + database: + image: postgres + container_name: greenpeace-postgres + ports: + - 5432:5432 + volumes: + - greenpeace-postgres-data:/var/lib/postgresql/data/ + environment: + - POSTGRES_USER=greenpeace + - POSTGRES_PASSWORD=greenpeace + - POSTGRES_DATABASE=greenpeace + restart: unless-stopped + api: + build: api/ + container_name: greenpeace-api + ports: + - 3000:3000 + volumes: + - ./api/:/app/ + environment: + - DATABASE_URL=postgresql://greenpeace:greenpeace@127.0.0.1:5432/greenpeace + restart: unless-stopped + +volumes: + greenpeace-postgres-data: \ No newline at end of file From cf0ea7b796a4b1d08992f50fb2e24ae505131a35 Mon Sep 17 00:00:00 2001 From: hanzili Date: Wed, 7 Feb 2024 19:39:48 -0500 Subject: [PATCH 4/4] chore: add README --- api/.env.example | 7 +++++++ api/.gitignore | 1 + api/README.md | 26 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 api/.env.example create mode 100644 api/README.md diff --git a/api/.env.example b/api/.env.example new file mode 100644 index 0000000..153f9d9 --- /dev/null +++ b/api/.env.example @@ -0,0 +1,7 @@ +# Environment variables declared in this file are automatically made available to Prisma. +# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema + +# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB. +# See the documentation for all the connection string options: https://pris.ly/d/connection-strings + +DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public" \ No newline at end of file diff --git a/api/.gitignore b/api/.gitignore index da30ba9..99b43e3 100644 --- a/api/.gitignore +++ b/api/.gitignore @@ -1,3 +1,4 @@ node_modules build/ *.db +.env \ No newline at end of file diff --git a/api/README.md b/api/README.md new file mode 100644 index 0000000..15713ff --- /dev/null +++ b/api/README.md @@ -0,0 +1,26 @@ +# Greenpeace Backend + +## Overview +The frontend of the application will serve the maps UI by accessing the Google Maps API and rendering the result using React, with additional components from Material UI. Our complete (frontend) tech stack is: +- Express.js +- Prisma + + +## Setup + +To create the `.env` file, copy the `.env.example` file, make sure you are in the `backend` folder and run the following: +``` +cp .env.example .env +``` + +Next, start the Docker Compose services, use the command: + +``` +docker-compose up +``` + + +--- + + +Feel free to add any issue in this file, or let the leads know! \ No newline at end of file