From b3f26d59ff7011466bc5998928b92995759dad85 Mon Sep 17 00:00:00 2001 From: Alexandre Bedel Date: Tue, 9 Apr 2024 13:23:23 +0200 Subject: [PATCH] #38 Setup for vercel psql done, improved the seed file & fixed build issues --- backend/package.json | 9 +++-- backend/prisma/schema.prisma | 3 +- backend/prisma/{seed.js => seed.ts} | 4 +- backend/src/app/components/DashboardTable.tsx | 40 +++++++++++-------- backend/src/app/components/LoginForm.tsx | 2 +- backend/tsconfig.json | 2 +- 6 files changed, 37 insertions(+), 23 deletions(-) rename backend/prisma/{seed.js => seed.ts} (83%) diff --git a/backend/package.json b/backend/package.json index a9bbe60a6..464d4c8ef 100644 --- a/backend/package.json +++ b/backend/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { - "dev": "next dev", + "dev": "prisma generate && next dev", "build": "next build", "start": "next start", "lint": "next lint", @@ -12,7 +12,7 @@ "prisma:g": "prisma generate", "prisma:m": "prisma migrate dev", "prisma:s": "prisma studio", - "seed": "node ./database/prisma/seed.js" + "vercel-build": "prisma generate && prisma db push && prisma db seed && next build" }, "dependencies": { "@hookform/resolvers": "^3.3.4", @@ -53,5 +53,8 @@ "ts-jest": "^29.1.2", "ts-node": "^10.9.2", "typescript": "^5" + }, + "prisma": { + "seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts" } -} +} \ No newline at end of file diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index 4923fc551..b8499b636 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -4,7 +4,8 @@ generator client { datasource db { provider = "postgresql" - url = env("DATABASE_URL") + url = env("POSTGRES_PRISMA_URL") // uses connection pooling + directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection } enum TrashType { diff --git a/backend/prisma/seed.js b/backend/prisma/seed.ts similarity index 83% rename from backend/prisma/seed.js rename to backend/prisma/seed.ts index 208ee8967..b3e8b24e1 100644 --- a/backend/prisma/seed.js +++ b/backend/prisma/seed.ts @@ -8,7 +8,9 @@ async function main() { const password = process.env.ADMIN_PASSWORD; if (!email || !password) { - console.error("Les variables d'environnement ADMIN_EMAIL ou ADMIN_PASSWORD ne sont pas définies."); + console.error( + "Les variables d'environnement ADMIN_EMAIL ou ADMIN_PASSWORD ne sont pas définies." + ); return; } diff --git a/backend/src/app/components/DashboardTable.tsx b/backend/src/app/components/DashboardTable.tsx index 18760c38f..7caa73456 100644 --- a/backend/src/app/components/DashboardTable.tsx +++ b/backend/src/app/components/DashboardTable.tsx @@ -1,6 +1,14 @@ import { format } from "date-fns"; import { fr } from "date-fns/locale"; -import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from "@/app/components/ui/table"; +import { + Table, + TableBody, + TableCaption, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/app/components/ui/table"; import { BinInfo } from "@/types"; import Link from "next/link"; import { Button } from "@/app/components/ui/button"; @@ -19,21 +27,21 @@ export default function DashboardTable({ bins }: { bins: BinInfo[] }) { - {bins.map((bin: BinInfo) => { - return ( - - {bin.id} - {format(bin.createdAt, "EEEE dd MMMM yyyy", { locale: fr })} - {bin.mostTypeTrash} - {bin.totalTrash} - - - - - - - ); - })} + {bins.map((bin: BinInfo) => ( + + {bin.id} + + {format(bin.createdAt, "EEEE dd MMMM yyyy", { locale: fr })} + + {bin.mostTypeTrash} + {bin.totalTrash} + + + + + + + ))} ); diff --git a/backend/src/app/components/LoginForm.tsx b/backend/src/app/components/LoginForm.tsx index 293ce4146..4895ebb93 100644 --- a/backend/src/app/components/LoginForm.tsx +++ b/backend/src/app/components/LoginForm.tsx @@ -45,7 +45,7 @@ export function LoginForm() { Connexion - Make changes to your account here. Click save when you're done. + Make changes to your account here. Click save when you're done.
diff --git a/backend/tsconfig.json b/backend/tsconfig.json index 1b3b97c8f..e59724b28 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -22,6 +22,6 @@ "@/*": ["./src/*"] } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "prisma/seed.js"], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "exclude": ["node_modules"] }