Skip to content

Commit

Permalink
Merge pull request #40 from alexandrebedel/feature/38-vercel-hosting
Browse files Browse the repository at this point in the history
Vercel hosting
  • Loading branch information
kodaa09 committed Apr 9, 2024
2 parents 3ca210f + 049b6e9 commit 2dcbefb
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 23 deletions.
9 changes: 6 additions & 3 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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"
}
}
}
3 changes: 2 additions & 1 deletion backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion backend/prisma/seed.js → backend/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
40 changes: 24 additions & 16 deletions backend/src/app/components/DashboardTable.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -19,21 +27,21 @@ export default function DashboardTable({ bins }: { bins: BinInfo[] }) {
</TableRow>
</TableHeader>
<TableBody>
{bins.map((bin: BinInfo) => {
return (
<TableRow>
<TableCell className="font-medium">{bin.id}</TableCell>
<TableCell>{format(bin.createdAt, "EEEE dd MMMM yyyy", { locale: fr })}</TableCell>
<TableCell>{bin.mostTypeTrash}</TableCell>
<TableCell>{bin.totalTrash}</TableCell>
<TableCell className="text-right">
<Link href={`/stats/${bin.id}`}>
<Button>Détails</Button>
</Link>
</TableCell>
</TableRow>
);
})}
{bins.map((bin: BinInfo) => (
<TableRow key={bin.id}>
<TableCell className="font-medium">{bin.id}</TableCell>
<TableCell>
{format(bin.createdAt, "EEEE dd MMMM yyyy", { locale: fr })}
</TableCell>
<TableCell>{bin.mostTypeTrash}</TableCell>
<TableCell>{bin.totalTrash}</TableCell>
<TableCell className="text-right">
<Link href={`/stats/${bin.id}`}>
<Button>Détails</Button>
</Link>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
);
Expand Down
2 changes: 1 addition & 1 deletion backend/src/app/components/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function LoginForm() {
<Card>
<CardHeader>
<CardTitle>Connexion</CardTitle>
<CardDescription>Make changes to your account here. Click save when you're done.</CardDescription>
<CardDescription>Make changes to your account here. Click save when you&apos;re done.</CardDescription>
</CardHeader>
<CardContent className="space-y-2">
<Form {...loginForm}>
Expand Down
2 changes: 1 addition & 1 deletion backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}

0 comments on commit 2dcbefb

Please sign in to comment.