ImanolTorres84 / CST438Project

3 stars 0 forks source link

Warnings

Getting Started

Install the following:

Learn the following:

Developing

Now run the following commands:

#
# These commands only need to be run once when you build the dev container!!!
#

# Start the postgres database.
service postgresql start
service postgresql status # check to make sure its running!
# switch to postgres account
su postgres
# create user
psql -c "CREATE USER pawsadmin WITH SUPERUSER PASSWORD 'pawspassword'";
# create database, this takes a few seconds
psql -c "CREATE DATABASE pawsconnect";
# back to root
exit
# install deps
npm install
# create the tables in the database.
npx -y prisma db push

This is the only command you need to run from the terminal from now on:

# Start postgresql
service postgresql start
# Start the development server
npm run dev

You should be able to go to http://localhost:3006 if everything works. You can also inspect the database using prisma studio by running the following command:

# This will make another web server to view the database.
npx prisma studio

Database

We are using Prisma and Postgres for our database.

Prisma

Prisma is an ORM that allows us to define schemas without writing any SQL. You can see examples of prisma here: https://playground.prisma.io/examples/reading/find/find-all?path=examples&host=playground.prisma.io

You will only be able to interface with the database if you are running inside of the dev container!

Prisma Migrations

Every single time you change prisma/schema.prisma you need to run the following commands to run migrations.

# Generates the Postgresql
npx prisma migrate dev --name "init"

# Generates the Typescript
npx -y prisma generate

Building

To create a production version of your app:

npm run build

You can preview the production build with npm run preview.

To deploy your app, you may need to install an adapter for your target environment.

Protected Routes

If you have a route which you dont want to be protected (aka require login) then go to src/hooks.server.js and add your route to the array unProtectedRoutes.

Env

You cannot use this framework without defining the following env vars:

DATABASE_URL="postgresql://[dbusername]:[dbpassword]@localhost:5432/pawsconnect"
GOOGLE_CLIENT_ID=[fill this in yourself]
GOOGLE_CLIENT_SECRET=[fill this in yourself]
AUTH_SECRET=[make this a random string, its required for authjs]

For google follow this page to get client id and client secret:

https://developers.google.com/workspace/guides/create-credentials

DO NOT USE YOUR SCHOOL EMAIL!