IngridGdesigns / Urban_Garden

Urban Garden is a food bartering app that reduces the impact of food waste, builds community, and creates an additional digital farmers’ barter market.
2 stars 2 forks source link
auth0 expressjs nodejs posgresql reactjs

Urban_Garden

by Ingrid García

desktop view: ingridg UB A Food barter app where you can exchange food grown in your garden with other urban farmers or anyone who wants to eat better, reduce food waste and form a community.

Where would it happen?

Demographic

Features

Styleguide

Tools

API - Created file based on two open source API's

Data

Techtonica Project

Shoutouts:

Thanks to: Tony, Julia, Shweta, Agrima, David, Shalani, Danielle, the cohort and everyone I might of missed who are great volunteers and that are awesome.

ingridg UB2

mobile view: ingridg UB5

to get started:

CREATING ENVIRONMENT && PROJECT

  1. open terminal

  2. mkdir - myproject

  3. make a folder for backend

  4. cd to backend dir

  5. brew install

  6. brew install node

  7. run npm init -y

    // to create a package json -add name, //github if you want remember to add entry point: (index.js or server.js)

Express.js & dependencies ---

  1. npm install express

  2. npm install dotenv

  3. create .gitignore file - add .env to file

  4. create .env file

  5. add it to .gitignore

  6. brew install postgresql - To work with posgres sql db

  7. psql postgres // to get it to connect to postgres database - log in

  8. postgres=# //Shows your inside psql postgres db and logged in as superuser or root.

  9. create role and password, CREATE ROLE me WITH LOGINPASSWORD ‘password’; //(hit return) then write, ALTER ROLE me CREATEDB //(we want to create db

  10. write \d to list all users/roles in postgres

  11. \q to quit postgres

  12. Now in terminal, to connect to ‘me’ write: psql -d postgres -U me �//(you are now logged in as me)

  13. (run command) CREATE DATABASE sweets;

  14. \c mytable //(to connect to sweets database)

  15. make a table - use postgresql docs to insert, create, update etc. example: CREATE TABLE mytable(id SERIAL PRIMARY KEY, name VARCHAR(20), description VARCHAR(25), order_date DATE;�

  16. after creating tables, open new tab in terminal bash

  17. Cd backend/ - go to backend folder, (inside)

  18. npm install pg //(node-postgres is a collection of node modules for interacting with PostgresSQL database. read node-postgres.com documentation

  19. use express.js documentation to instantiate express connections

  20. go back to .env file and fix according to posgres CRUD passwords, etc.

  21. npm install -g nodemon (to be run globally)

  22. to start it just write nodemon [your node app, server.js or index.js

  23. use port 3001 or 3005, (react app opens http://localhost:3000 )

  24. npm install express-jwt-authz

  25. npm install jsonwebtoken

  26. npm install --save jwks-rsa

  27. npm install cors

  28. npm install body-parser

  29. npm install morgan

    body-parser: This is a library that you will use to convert the body of incoming requests into JSON objects.

    cors: This is a library that you will use to configure Express to add headers stating that your API accepts requests coming from other origins. This is also known as Cross-Origin Resource Sharing (CORS).

    express: This is Express itself.

    morgan: This is a library that adds some logging capabilities to your Express app.

Front end

make another directory in root folder, call it client and type:

  1. npx create-react-app my-cool-app OR ### yarn create react-app my-app

  2. cd my-cool-app and npm start to see that its running on port 3000

  3. my-cool-app’s package.json add (make sure it is the last object), ”proxy": "http://localhost:3005”} . - this is the express port to get your api’s

  4. npm install react-router

  5. npm install react-bootstrap

  6. yarn add popper.js

  7. npm install auth0 - Auth0 authentication

  8. npm install react-icons - library of Fa icons and Glyphicons

  9. npm install react-moment (&& moment && moment-timezone if needed see moment.js documentation) -

  10. npm axios (only used to get users from Auth0) - fetch's cool brother

  11. create account with Auth0, follow documentation for react SPA & look into securing backend -- see node guidelines in Auth0 for users.