Fotofacts is an app used to organize your photo collection. Each individual user can create a profile, or login through github, upload a photowith all specific details of the event and see a library of their Photos in one place.
So if you have you ever looked through your photos and forgot the details associated with a photo (event title, attendees, etc.) and wished you could recall that memory. No need to fret Fotofacts is the resolution.
- HTML
- CSS
- JAVASCRIPT
- GITHUB
- JSON
- BOOTSTRAP
- HEROKU
- NPM PACKAGE MANAGER
- POSTGRES DATABASE
- SEQULIZE ORM
- PASSPORT.JS
- DOG API
- Check if you have homebrew already installed
brew -v
- If it is not installed, install it
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- If you are asked for your computer's password, enter it at the prompt
- Press
RETURN
to continue - Confirm that homebrew is installed with
brew -v
- Check to see if PostgreSQL is already installed
psql --version
- If PostgreSQL is not installed, use homebrew to install it
brew install postgresql
- Confirm that PostgreSQL is installed with
psql --version
- Start the database server
brew services start postgresql
- Initialize a shell to interact with the database
psql postgres
- You know you are in the shell if you see a prompt that begins with
#
- While in the shell, list the databases with
\l
- Enter
q
to quit the listing of databases - Create a new role
CREATE ROLE dev_admin LOGIN PASSWORD 'admin';
- Alter its permissions so that this new role is a superuser
ALTER USER dev_admin WITH SUPERUSER;
- Verify that the role and permission level is created with
\du
- In a browser, navigate to your account in GitHub
- Click on your avatar in the upper right
- Click settings
- Click Developer settings
- Click oAuth apps
- Click Register a new application
- Complete the fields as follows
Application name -> gh-oauth-psql-demo
Homepage URL -> http://locahost:8080
Authorization callback URL -> http://localhost:8080/auth/github/callback
- Click Register Application
- Copy Client ID and keep it somewhere you can get at it again
- Click Generate a new client secret
- Enter your GitHub password to confirm the last step
- Copy Client secret and keep it somewhere you can get at it again
- Upload a logo (optional)
- Click Update application
- Open the project in in VSCode
- Duplicate .env-example
- Rename this duplicated file to .env
- Fill in the missing values while making sure there are no spaces
GITHUB_CLIENT_ID=**\*\***
GITHUB_CLIENT_SECRET=
DB_HOST=localhost
DB_PORT=5432
DB_NAME=fotofacts
DB_USER=<fill in Windows only>
DB_PASS=<fill in Windows only>
// inside of your .env file
- Open a new terminal instance within VSCode
- Using the terminal instance, create the database
npx sequelize-cli db:create
- Open new PostgreSQL shell instance within VSCode
psql postgres
- List the databases with
\l
and verify that the database gh_oauth_psql_demo_dev has been created - Using the terminal instance, run a migration in order to build the Users table
npx sequelize-cli db:migrate
- Return to the PostgreSQL shell instance and connect to the database that was created in step 36
\c gh_oauth_psql_demo_dev
- Verify that the Users table was created (note that it will not have any rows)
SELECT * FROM "Users";
- Using the terminal instance, start the application
npm run dev
- In a browser, navigate to localhost:8080
- Click Login
- At the GitHub prompt, click Authorize this application
- In the PostgreSQL shell, execute
SELECT * FROM "Users";
to verify that you are now a user listed in the database
Routes for Photos (Users coming soon)
HTTP Verb | Route | RESTful description | Purpose |
---|---|---|---|
GET | * | catchAll | 404 error handling. |
GET | /heartbeat | resSend | Sanity check. |
GET | / | static page | FotoFacts homepage. |
GET | /auth/github | passportGithubAuth | Sets Github Auth. |
GET | /auth/github/callback | passportGithubCB | Call back action for Github Auth. |
- User
Attribute | Example value |
---|---|
avatarURL | https://placeimg.com/128/128/any |
firstName | Junghae |
lastName | Moon |
[email protected] |
- Photo
Attribute | Example value |
---|---|
title | Eating at Costco |
category | vacation |
attendee1FirstName | SoJong |
attendee1LastName | Lee |
attendee2FirstName | Teila |
attendee2LastName | Jones |
attendee3FirstName | Avery |
attendee3LastName | Song |
description | After a long week |
url | http://placeimg.com/640/480/food |
- Users Model:
npx sequelize-cli model:generate --name User --attributes firstName:string,lastName:string,email:string,avatarURL:string,loginStrategy:string,loginStrategyId:string,username:string
- Photo Model:
npx sequelize-cli model:generate --name Photo --attributes title:string,category:string,attendee1FirstName:string,attendee1LastName:string,attendee2FirstName:string,attendee2LastName:string,attendee3FirstName:string,attendee3LastName:string,description:string,url:string,userId:integer