Skip to content

Commit

Permalink
feat[SUPABASE & PRISMA]: Create db for the application
Browse files Browse the repository at this point in the history
Using prisma ORM and Vercel / supabase for .env, added .env.example
  • Loading branch information
parazeeknova committed Oct 5, 2024
1 parent 8bf9bdf commit 17d1535
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 5 deletions.
File renamed without changes.
File renamed without changes.
Binary file modified apps/web/src/app/favicon.ico
Binary file not shown.
6 changes: 3 additions & 3 deletions apps/web/src/app/fonts.css
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
@font-face {
font-family: "SofiaProReg";
src: url("../public/fonts/SofiaProSoftReg.woff2") format("woff2");
src: url("../../public/fonts/SofiaProSoftReg.woff2") format("woff2");
font-weight: 400;
font-style: normal;
font-display: swap;
}

@font-face {
font-family: "SofiaProBold";
src: url("../public/fonts/SofiaProSoftBold.woff2") format("woff2");
src: url("../../public/fonts/SofiaProSoftBold.woff2") format("woff2");
font-weight: 700;
font-style: normal;
font-display: swap;
}

@font-face {
font-family: "SofiaProMed";
src: url("../public/fonts/SofiaProSoftMed.woff2") format("woff2");
src: url("../../public/fonts/SofiaProSoftMed.woff2") format("woff2");
font-weight: 500;
font-style: normal;
font-display: swap;
Expand Down
15 changes: 15 additions & 0 deletions packages/db/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Get this from vercel supabase secrets

POSTGRES_URL="postgres://<username>:<password>@<host>:<port>/<database>?sslmode=require&supa=base-pooler.x"
POSTGRES_PRISMA_URL="postgres://<username>:<password>@<host>:<port>/<database>?sslmode=require&supa=base-pooler.x"
SUPABASE_URL="https://<project>.supabase.co"
NEXT_PUBLIC_SUPABASE_URL="https://<project>.supabase.co"
POSTGRES_URL_NON_POOLING="postgres://<username>:<password>@<host>:<port>/<database>?sslmode=require"
SUPABASE_JWT_SECRET="<your-jwt-secret>"
POSTGRES_USER="<username>"
NEXT_PUBLIC_SUPABASE_ANON_KEY="<your-anon-key>"
POSTGRES_PASSWORD="<password>"
POSTGRES_DATABASE="<database>"
SUPABASE_SERVICE_ROLE_KEY="<your-service-role-key>"
POSTGRES_HOST="<host>"
SUPABASE_ANON_KEY="<your-anon-key>"
3 changes: 3 additions & 0 deletions packages/db/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
# Keep environment variables out of version control
.env
10 changes: 8 additions & 2 deletions packages/db/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
"license": "AGPL-3.0",
"private": true,
"dependencies": {
"@prisma/client": "^5.20.0",
"prisma": "^5.20.0"
"@prisma/client": "^5.20.0"
},
"devDependencies": {
"@types/node": "^22.7.4",
"@zephyr/config": "workspace:*",
"prisma": "^5.20.0",
"ts-node": "^10.9.2",
"typescript": "^5.6.2"
}
}
15 changes: 15 additions & 0 deletions packages/db/prisma/prisma.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { PrismaClient } from "@prisma/client";

const prismaClientSingleton = () => {
return new PrismaClient();
};

declare global {
var prismaGlobal: undefined | ReturnType<typeof prismaClientSingleton>;
}

const prisma = globalThis.prismaGlobal ?? prismaClientSingleton();

export default prisma;

if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma;
16 changes: 16 additions & 0 deletions packages/db/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init

generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch"]
}

datasource db {
provider = "postgresql"
url = env("POSTGRES_PRISMA_URL") // uses connection pooling
directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection
}
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 17d1535

Please sign in to comment.