Skip to content

Commit

Permalink
merge main package.json and lock
Browse files Browse the repository at this point in the history
  • Loading branch information
CassandraGoose committed Jan 18, 2024
2 parents 8983c4e + 9f84900 commit 5a75e58
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 463 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
Deploy-Production:
needs: test
env:
NODE_ENV: ${{ secrets.NODE_ENV }}
DATABASE_URL: ${{ secrets.DATABASE_URL}}
TEST_USER_EMAIL: ${{ secrets.TEST_USER_EMAIL }}
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next
Set up the env:

- you'll need the following values in your .env: DATABASE_URL, TEST_USER_ID
- the database URL should match a PostgreSQL db.
- the database URL should match a PostgreSQL db. Note that I've created this application with connection pooling through PgBouncer according to Prisma's statement "For Prisma Client to work relialy, PgBouncer must run in transaction mod. Add `pgbouncer=true` to the connection URL"

Create tables in your db:

Expand Down
8 changes: 6 additions & 2 deletions app/lib/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ const global = globalThis as unknown as {
prisma: PrismaClient | undefined;
}
if (process.env.NODE_ENV === 'production') {
prisma = new PrismaClient();
prisma = new PrismaClient({
datasourceUrl: process.env.DATABASE_URL,
});
} else {
if (!global.prisma) {
global.prisma = new PrismaClient();
global.prisma = new PrismaClient({
datasourceUrl: process.env.DATABASE_URL,
});
}
prisma = global.prisma;
}
Expand Down
10 changes: 6 additions & 4 deletions app/lib/queries.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import prisma from '@/app/lib/prisma';

export async function getPathwaysByEmail() {
return await prisma.person.findFirst({
export function getPathwaysByEmail() {
return prisma.person.findFirst({
where: {
email: process.env.TEST_USER_EMAIL,
},
Expand All @@ -23,8 +23,10 @@ export async function getPathwaysByEmail() {
});
}

export async function getPathwayByUserId(userId:string, pathwayId:string) {
return await prisma.person.findFirst({
export function getPathwayByUserId(userId:string, pathwayId:string) {
console.log('prod debug pathway: ', pathwayId);
console.log('prod debug user:', userId);
return prisma.person.findFirst({
where: {
id: userId,
},
Expand Down
Loading

0 comments on commit 5a75e58

Please sign in to comment.