This is a project for learning the PERN stack
- PostgreSQL
- ExpressJS
- ReactJS
- NodeJS
- start postgresql database in terminal window
- run: psql -U DB_USERNAME
- enter DB_PASSWORD
- in psql command line
- Connect to "perntodo" database: \c perntodo
- to list databases: \l
- to see schema: \dt
- Connect to "perntodo" database: \c perntodo
- run: psql -U DB_USERNAME
- set up .env file in server directory
- DB_USERNAME=...
- DB_PASSWORD=...
- DB_NAME=...
- HOST=...
- PORT=...
- in another terminal, in server directory run: nodemon
- make sure corsConfig.js allows the address and port# from front-end
- in another terminal, in frontend/vite-project directory run: npm run dev
- while in vite CLI enter "o" if a browser did not open yet
- set up .gitignore and .env files
- in terminal run psql and enter the username(the superuser) and password
- now you can perform the sql commands
- create database
- create tables
- on first start
- npm init //to install node
- npm i express cors pg //to install cors expressJS and postgres
- as seen in db.js create the pool to access the postgresql database
- good practice to use env file to not share private info in a public repository
- as seen in index.js set up the require statements and middleware
- create CRUD operations in index.js
- have server start listening on a port (ex: port 5000)
- when using localhost port 5000 on a MacOS you have to disable General>AirDrop & Handoff>AirPlay Reciever in order to free up port 5000
- when installing postgresql for first time, the command psql was not found. So to fix it, go into terminal
- vi ~/.zshrc
- go to bottom of file with arrow keys, press i to insert
- type: export PATH=/Library/PostgreSQL/17/bin/:$PATH
- press ESC then :wq to save and quit the editor
- restart terminal session and run the psql command