Skip to content

ReactThreeShowroom/api

Repository files navigation

ReactThreeShowroom

Structure of .env file

PG_USER=<pg username>
PG_PASSWORD=<password for pg user>
DB_ADDRESS=<localhost for dev>
DB_PORT=<default is 5432>
DB_NAME=<whatever you choose, default for this project is devShowroom>
DB_SCHEMA=<default is public>
// the below build generates interpolation for the above values
DATABASE_URL="postgresql://${PG_USER}:${PG_PASSWORD}@${DB_ADDRESS}:${DB_PORT}/${DB_NAME}?schema=${DB_SCHEMA}"

structure of schema.prisma file

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

Setting up Database

run command:
createdb devShowroom
or in psql:
create database devShowroom;
next run the migrate command from prisma:
npx prisma migrate dev --name init

Routes

  • /client
  • /favorite
  • /user
  • /auth
  • /

Dev Server

The Development Server has an extra route /seed

Create a post to the /seed route to perform a migrate reset --force --skip-seed --skip-generate command, followed by an attempt to create users. If there is no migration file, a backup function runs migrate dev --name init and then attemptes to perform the rebuildDB function again for seeding.

curl -X POST http://localhost:3000/seed

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published