correction prisma v2
This commit is contained in:
BIN
build_output.txt
Normal file
BIN
build_output.txt
Normal file
Binary file not shown.
64
build_output2.txt
Normal file
64
build_output2.txt
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
> plumeia@0.1.0 build
|
||||
> npx prisma generate && next build
|
||||
|
||||
[dotenv@17.3.1] injecting env (4) from .env -- tip: ⚙️ specify custom .env file path with { path: '/custom/path/.env' }
|
||||
[dotenv@17.3.1] injecting env (0) from .env.local -- tip: ⚙️ suppress all logs with { quiet: true }
|
||||
Loaded Prisma config from prisma.config.ts.
|
||||
|
||||
Prisma schema loaded from prisma\schema.prisma.
|
||||
|
||||
✔ Generated Prisma Client (v7.4.1) to .\node_modules\@prisma\client in 72ms
|
||||
|
||||
Start by importing your Prisma Client (See: https://pris.ly/d/importing-client)
|
||||
|
||||
|
||||
⚠ Warning: Next.js inferred your workspace root, but it may not be correct.
|
||||
We detected multiple lockfiles and selected the directory of C:\Users\streaper2\package-lock.json as the root directory.
|
||||
To silence this warning, set `turbopack.root` in your Next.js config, or consider removing one of the lockfiles if it's not needed.
|
||||
See https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#root-directory for more information.
|
||||
Detected additional lockfiles:
|
||||
* C:\Users\streaper2\Documents\00 - projet\plumeia\package-lock.json
|
||||
|
||||
▲ Next.js 16.1.6 (Turbopack)
|
||||
- Environments: .env
|
||||
|
||||
Creating an optimized production build ...
|
||||
✓ Compiled successfully in 1183.7ms
|
||||
Skipping validation of types
|
||||
Collecting page data using 31 workers ...
|
||||
Error [PrismaClientInitializationError]: `PrismaClient` needs to be constructed with a non-empty, valid `PrismaClientOptions`:
|
||||
|
||||
```
|
||||
new PrismaClient({
|
||||
...
|
||||
})
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
constructor() {
|
||||
super({ ... });
|
||||
}
|
||||
```
|
||||
|
||||
at a (C:\Users\streaper2\Documents\00 - projet\plumeia\.next\server\chunks\[root-of-the-server]__bcb19414._.js:1:1488)
|
||||
at module evaluation (C:\Users\streaper2\Documents\00 - projet\plumeia\.next\server\chunks\[root-of-the-server]__bcb19414._.js:1:1523)
|
||||
at instantiateModule (C:\Users\streaper2\Documents\00 - projet\plumeia\.next\server\chunks\[turbopack]_runtime.js:740:9)
|
||||
at getOrInstantiateModuleFromParent (C:\Users\streaper2\Documents\00 - projet\plumeia\.next\server\chunks\[turbopack]_runtime.js:763:12)
|
||||
at Context.esmImport [as i] (C:\Users\streaper2\Documents\00 - projet\plumeia\.next\server\chunks\[turbopack]_runtime.js:228:20)
|
||||
at <unknown> (C:\Users\streaper2\Documents\00 - projet\plumeia\.next\server\chunks\[root-of-the-server]__bcb19414._.js:1:2288)
|
||||
at Context.asyncModule [as a] (C:\Users\streaper2\Documents\00 - projet\plumeia\.next\server\chunks\[turbopack]_runtime.js:455:5)
|
||||
at module evaluation (C:\Users\streaper2\Documents\00 - projet\plumeia\.next\server\chunks\[root-of-the-server]__bcb19414._.js:1:2235)
|
||||
at instantiateModule (C:\Users\streaper2\Documents\00 - projet\plumeia\.next\server\chunks\[turbopack]_runtime.js:740:9) {
|
||||
clientVersion: '7.4.1',
|
||||
errorCode: undefined,
|
||||
retryable: undefined
|
||||
}
|
||||
|
||||
> Build error occurred
|
||||
Error: Failed to collect page data for /api/ai/generate
|
||||
at ignore-listed frames {
|
||||
type: 'Error'
|
||||
}
|
||||
71
build_output3.txt
Normal file
71
build_output3.txt
Normal file
@@ -0,0 +1,71 @@
|
||||
|
||||
> plumeia@0.1.0 build
|
||||
> npx prisma generate && next build
|
||||
|
||||
[dotenv@17.3.1] injecting env (4) from .env -- tip: 🛠️ run anywhere with `dotenvx run -- yourcommand`
|
||||
[dotenv@17.3.1] injecting env (0) from .env.local -- tip: ⚙️ enable debug logging with { debug: true }
|
||||
Loaded Prisma config from prisma.config.ts.
|
||||
|
||||
Prisma schema loaded from prisma\schema.prisma.
|
||||
|
||||
✔ Generated Prisma Client (v7.4.1) to .\node_modules\@prisma\client in 75ms
|
||||
|
||||
Start by importing your Prisma Client (See: https://pris.ly/d/importing-client)
|
||||
|
||||
|
||||
⚠ Warning: Next.js inferred your workspace root, but it may not be correct.
|
||||
We detected multiple lockfiles and selected the directory of C:\Users\streaper2\package-lock.json as the root directory.
|
||||
To silence this warning, set `turbopack.root` in your Next.js config, or consider removing one of the lockfiles if it's not needed.
|
||||
See https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#root-directory for more information.
|
||||
Detected additional lockfiles:
|
||||
* C:\Users\streaper2\Documents\00 - projet\plumeia\package-lock.json
|
||||
|
||||
▲ Next.js 16.1.6 (Turbopack)
|
||||
- Environments: .env
|
||||
|
||||
Creating an optimized production build ...
|
||||
✓ Compiled successfully in 1196.6ms
|
||||
Skipping validation of types
|
||||
Collecting page data using 31 workers ...
|
||||
Generating static pages using 31 workers (0/10) ...
|
||||
Generating static pages using 31 workers (2/10)
|
||||
Generating static pages using 31 workers (4/10)
|
||||
Generating static pages using 31 workers (7/10)
|
||||
✓ Generating static pages using 31 workers (10/10) in 359.6ms
|
||||
Finalizing page optimization ...
|
||||
|
||||
Route (app)
|
||||
┌ ○ /
|
||||
├ ○ /_not-found
|
||||
├ ƒ /api/ai/generate
|
||||
├ ƒ /api/ai/transform
|
||||
├ ƒ /api/auth/[...nextauth]
|
||||
├ ƒ /api/auth/register
|
||||
├ ƒ /api/chapters
|
||||
├ ƒ /api/chapters/[id]
|
||||
├ ƒ /api/entities
|
||||
├ ƒ /api/entities/[id]
|
||||
├ ƒ /api/ideas
|
||||
├ ƒ /api/ideas/[id]
|
||||
├ ƒ /api/plans
|
||||
├ ƒ /api/projects
|
||||
├ ƒ /api/projects/[id]
|
||||
├ ƒ /api/projects/[id]/workflow
|
||||
├ ƒ /api/user/profile
|
||||
├ ○ /checkout
|
||||
├ ○ /dashboard
|
||||
├ ○ /features
|
||||
├ ○ /login
|
||||
├ ○ /pricing
|
||||
├ ○ /profile
|
||||
├ ƒ /project/[id]
|
||||
├ ƒ /project/[id]/ideas
|
||||
├ ƒ /project/[id]/settings
|
||||
├ ƒ /project/[id]/workflow
|
||||
├ ƒ /project/[id]/world
|
||||
└ ○ /signup
|
||||
|
||||
|
||||
○ (Static) prerendered as static content
|
||||
ƒ (Dynamic) server-rendered on demand
|
||||
|
||||
2
next-env.d.ts
vendored
2
next-env.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
import "./.next/dev/types/routes.d.ts";
|
||||
import "./.next/types/routes.d.ts";
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "rm -rf .next && npx prisma generate && next build",
|
||||
"build": "npx prisma generate && next build",
|
||||
"start": "npx prisma db push && next start",
|
||||
"lint": "next lint"
|
||||
},
|
||||
|
||||
@@ -2,7 +2,8 @@ export const dynamic = 'force-dynamic';
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { auth } from '@/lib/auth';
|
||||
import getDB from '@/lib/prisma';
|
||||
// 1. On remplace l'import de getDB par l'objet prisma direct
|
||||
import { prisma } from '@/lib/prisma';
|
||||
|
||||
// PUT /api/chapters/[id] — Update a chapter
|
||||
export async function PUT(
|
||||
@@ -17,8 +18,8 @@ export async function PUT(
|
||||
const { id } = await params;
|
||||
const body = await request.json();
|
||||
|
||||
// Verify ownership via project
|
||||
const chapter = await getDB().chapter.findUnique({
|
||||
// 2. On utilise 'prisma' au lieu de 'getDB()'
|
||||
const chapter = await prisma.chapter.findUnique({
|
||||
where: { id },
|
||||
include: { project: { select: { userId: true } } },
|
||||
});
|
||||
@@ -26,7 +27,7 @@ export async function PUT(
|
||||
return NextResponse.json({ error: 'Non trouvé' }, { status: 404 });
|
||||
}
|
||||
|
||||
const updated = await getDB().chapter.update({
|
||||
const updated = await prisma.chapter.update({
|
||||
where: { id },
|
||||
data: {
|
||||
...(body.title !== undefined && { title: body.title }),
|
||||
@@ -51,7 +52,8 @@ export async function DELETE(
|
||||
|
||||
const { id } = await params;
|
||||
|
||||
const chapter = await getDB().chapter.findUnique({
|
||||
// 3. On utilise 'prisma' au lieu de 'getDB()'
|
||||
const chapter = await prisma.chapter.findUnique({
|
||||
where: { id },
|
||||
include: { project: { select: { userId: true } } },
|
||||
});
|
||||
@@ -59,7 +61,7 @@ export async function DELETE(
|
||||
return NextResponse.json({ error: 'Non trouvé' }, { status: 404 });
|
||||
}
|
||||
|
||||
await getDB().chapter.delete({ where: { id } });
|
||||
await prisma.chapter.delete({ where: { id } });
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
}
|
||||
@@ -2,7 +2,8 @@ export const dynamic = 'force-dynamic';
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { auth } from '@/lib/auth';
|
||||
import getDB from '@/lib/prisma';
|
||||
// 1. On importe l'objet prisma au lieu de la fonction getDB
|
||||
import { prisma } from '@/lib/prisma';
|
||||
|
||||
// POST /api/chapters — Create a chapter
|
||||
export async function POST(request: NextRequest) {
|
||||
@@ -13,15 +14,17 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
const body = await request.json();
|
||||
|
||||
// Verify project ownership
|
||||
const project = await getDB().project.findFirst({
|
||||
// 2. On utilise 'prisma' directement au lieu de 'getDB()'
|
||||
const project = await prisma.project.findFirst({
|
||||
where: { id: body.projectId, userId: session.user.id },
|
||||
});
|
||||
|
||||
if (!project) {
|
||||
return NextResponse.json({ error: 'Projet non trouvé' }, { status: 404 });
|
||||
}
|
||||
|
||||
const chapter = await getDB().chapter.create({
|
||||
// 3. Pareil ici pour la création
|
||||
const chapter = await prisma.chapter.create({
|
||||
data: {
|
||||
title: body.title || 'Nouveau Chapitre',
|
||||
content: body.content || '',
|
||||
|
||||
@@ -2,7 +2,7 @@ export const dynamic = 'force-dynamic';
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { auth } from '@/lib/auth';
|
||||
import getDB from '@/lib/prisma';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
|
||||
// PUT /api/entities/[id]
|
||||
export async function PUT(
|
||||
@@ -17,7 +17,7 @@ export async function PUT(
|
||||
const { id } = await params;
|
||||
const body = await request.json();
|
||||
|
||||
const entity = await getDB().entity.findUnique({
|
||||
const entity = await prisma.entity.findUnique({
|
||||
where: { id },
|
||||
include: { project: { select: { userId: true } } },
|
||||
});
|
||||
@@ -25,7 +25,7 @@ export async function PUT(
|
||||
return NextResponse.json({ error: 'Non trouvé' }, { status: 404 });
|
||||
}
|
||||
|
||||
const updated = await getDB().entity.update({
|
||||
const updated = await prisma.entity.update({
|
||||
where: { id },
|
||||
data: {
|
||||
...(body.name !== undefined && { name: body.name }),
|
||||
@@ -53,7 +53,7 @@ export async function DELETE(
|
||||
|
||||
const { id } = await params;
|
||||
|
||||
const entity = await getDB().entity.findUnique({
|
||||
const entity = await prisma.entity.findUnique({
|
||||
where: { id },
|
||||
include: { project: { select: { userId: true } } },
|
||||
});
|
||||
@@ -61,7 +61,7 @@ export async function DELETE(
|
||||
return NextResponse.json({ error: 'Non trouvé' }, { status: 404 });
|
||||
}
|
||||
|
||||
await getDB().entity.delete({ where: { id } });
|
||||
await prisma.entity.delete({ where: { id } });
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ export const dynamic = 'force-dynamic';
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { auth } from '@/lib/auth';
|
||||
import getDB from '@/lib/prisma';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
|
||||
// POST /api/entities — Create an entity
|
||||
export async function POST(request: NextRequest) {
|
||||
@@ -13,14 +13,14 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
const body = await request.json();
|
||||
|
||||
const project = await getDB().project.findFirst({
|
||||
const project = await prisma.project.findFirst({
|
||||
where: { id: body.projectId, userId: session.user.id },
|
||||
});
|
||||
if (!project) {
|
||||
return NextResponse.json({ error: 'Projet non trouvé' }, { status: 404 });
|
||||
}
|
||||
|
||||
const entity = await getDB().entity.create({
|
||||
const entity = await prisma.entity.create({
|
||||
data: {
|
||||
type: body.type,
|
||||
name: body.name || 'Nouvelle entité',
|
||||
|
||||
@@ -2,7 +2,7 @@ export const dynamic = 'force-dynamic';
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { auth } from '@/lib/auth';
|
||||
import getDB from '@/lib/prisma';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
|
||||
// PUT /api/ideas/[id]
|
||||
export async function PUT(
|
||||
@@ -17,7 +17,7 @@ export async function PUT(
|
||||
const { id } = await params;
|
||||
const body = await request.json();
|
||||
|
||||
const idea = await getDB().idea.findUnique({
|
||||
const idea = await prisma.idea.findUnique({
|
||||
where: { id },
|
||||
include: { project: { select: { userId: true } } },
|
||||
});
|
||||
@@ -25,7 +25,7 @@ export async function PUT(
|
||||
return NextResponse.json({ error: 'Non trouvé' }, { status: 404 });
|
||||
}
|
||||
|
||||
const updated = await getDB().idea.update({
|
||||
const updated = await prisma.idea.update({
|
||||
where: { id },
|
||||
data: {
|
||||
...(body.title !== undefined && { title: body.title }),
|
||||
@@ -50,7 +50,7 @@ export async function DELETE(
|
||||
|
||||
const { id } = await params;
|
||||
|
||||
const idea = await getDB().idea.findUnique({
|
||||
const idea = await prisma.idea.findUnique({
|
||||
where: { id },
|
||||
include: { project: { select: { userId: true } } },
|
||||
});
|
||||
@@ -58,7 +58,7 @@ export async function DELETE(
|
||||
return NextResponse.json({ error: 'Non trouvé' }, { status: 404 });
|
||||
}
|
||||
|
||||
await getDB().idea.delete({ where: { id } });
|
||||
await prisma.idea.delete({ where: { id } });
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ export const dynamic = 'force-dynamic';
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { auth } from '@/lib/auth';
|
||||
import getDB from '@/lib/prisma';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
|
||||
// POST /api/ideas
|
||||
export async function POST(request: NextRequest) {
|
||||
@@ -13,14 +13,14 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
const body = await request.json();
|
||||
|
||||
const project = await getDB().project.findFirst({
|
||||
const project = await prisma.project.findFirst({
|
||||
where: { id: body.projectId, userId: session.user.id },
|
||||
});
|
||||
if (!project) {
|
||||
return NextResponse.json({ error: 'Projet non trouvé' }, { status: 404 });
|
||||
}
|
||||
|
||||
const idea = await getDB().idea.create({
|
||||
const idea = await prisma.idea.create({
|
||||
data: {
|
||||
title: body.title || 'Nouvelle idée',
|
||||
description: body.description || '',
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import getDB from '@/lib/prisma';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const prisma = getDB();
|
||||
//const prisma = getDB();
|
||||
const plans = await prisma.plan.findMany({
|
||||
orderBy: { price: 'asc' }
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ export const dynamic = 'force-dynamic';
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { auth } from '@/lib/auth';
|
||||
import getDB from '@/lib/prisma';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
|
||||
// GET /api/projects/[id] — Get project with all related data
|
||||
export async function GET(
|
||||
@@ -16,7 +16,7 @@ export async function GET(
|
||||
|
||||
const { id } = await params;
|
||||
|
||||
const project = await getDB().project.findFirst({
|
||||
const project = await prisma.project.findFirst({
|
||||
where: { id, userId: session.user.id },
|
||||
include: {
|
||||
chapters: { orderBy: { orderIndex: 'asc' } },
|
||||
@@ -48,14 +48,14 @@ export async function PUT(
|
||||
const body = await request.json();
|
||||
|
||||
// Verify ownership
|
||||
const existing = await getDB().project.findFirst({
|
||||
const existing = await prisma.project.findFirst({
|
||||
where: { id, userId: session.user.id },
|
||||
});
|
||||
if (!existing) {
|
||||
return NextResponse.json({ error: 'Projet non trouvé' }, { status: 404 });
|
||||
}
|
||||
|
||||
const project = await getDB().project.update({
|
||||
const project = await prisma.project.update({
|
||||
where: { id },
|
||||
data: {
|
||||
...(body.title !== undefined && { title: body.title }),
|
||||
@@ -81,14 +81,14 @@ export async function DELETE(
|
||||
const { id } = await params;
|
||||
|
||||
// Verify ownership
|
||||
const existing = await getDB().project.findFirst({
|
||||
const existing = await prisma.project.findFirst({
|
||||
where: { id, userId: session.user.id },
|
||||
});
|
||||
if (!existing) {
|
||||
return NextResponse.json({ error: 'Projet non trouvé' }, { status: 404 });
|
||||
}
|
||||
|
||||
await getDB().project.delete({ where: { id } });
|
||||
await prisma.project.delete({ where: { id } });
|
||||
|
||||
return NextResponse.json({ success: true });
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
import type { Prisma } from '@prisma/client';
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { auth } from '@/lib/auth';
|
||||
import getDB from '@/lib/prisma';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
|
||||
// PUT /api/projects/[id]/workflow — Sync workflow (nodes + connections)
|
||||
export async function PUT(
|
||||
@@ -15,7 +16,7 @@ export async function PUT(
|
||||
}
|
||||
|
||||
const { id } = await params;
|
||||
const prisma = getDB();
|
||||
//const prisma = getDB();
|
||||
|
||||
// Verify ownership
|
||||
const project = await prisma.project.findFirst({
|
||||
@@ -28,7 +29,7 @@ export async function PUT(
|
||||
const { nodes, connections } = await request.json();
|
||||
|
||||
// Replace all nodes and connections in a transaction
|
||||
await prisma.$transaction(async (tx) => {
|
||||
await prisma.$transaction(async (tx: Prisma.TransactionClient) => {
|
||||
// Delete existing
|
||||
await tx.plotConnection.deleteMany({ where: { projectId: id } });
|
||||
await tx.plotNode.deleteMany({ where: { projectId: id } });
|
||||
|
||||
@@ -2,7 +2,7 @@ export const dynamic = 'force-dynamic';
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { auth } from '@/lib/auth';
|
||||
import getDB from '@/lib/prisma';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
|
||||
// GET /api/projects — List all user's projects
|
||||
export async function GET() {
|
||||
@@ -11,7 +11,7 @@ export async function GET() {
|
||||
return NextResponse.json({ error: 'Non autorisé' }, { status: 401 });
|
||||
}
|
||||
|
||||
const projects = await getDB().project.findMany({
|
||||
const projects = await prisma.project.findMany({
|
||||
where: { userId: session.user.id },
|
||||
orderBy: { updatedAt: 'desc' },
|
||||
include: {
|
||||
@@ -32,7 +32,6 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
// Check plan limits
|
||||
const prisma = getDB();
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { id: session.user.id },
|
||||
include: { subscriptionPlan: true }
|
||||
|
||||
@@ -2,7 +2,7 @@ export const dynamic = 'force-dynamic';
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { auth } from '@/lib/auth';
|
||||
import getDB from '@/lib/prisma';
|
||||
import { prisma } from '@/lib/prisma';
|
||||
|
||||
// GET /api/user/profile — Get current user profile with stats
|
||||
export async function GET() {
|
||||
@@ -11,7 +11,7 @@ export async function GET() {
|
||||
return NextResponse.json({ error: 'Non autorisé' }, { status: 401 });
|
||||
}
|
||||
|
||||
const prisma = getDB();
|
||||
//const prisma = getDB();
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { id: session.user.id },
|
||||
include: { subscriptionPlan: true }
|
||||
@@ -27,7 +27,7 @@ export async function GET() {
|
||||
select: { content: true },
|
||||
});
|
||||
|
||||
const totalWords = chapters.reduce((total, chapter) => {
|
||||
const totalWords = chapters.reduce((total: number, chapter: { content: string | null }) => {
|
||||
const text = (chapter.content || '').replace(/<[^>]*>/g, ' ').trim();
|
||||
return total + (text ? text.split(/\s+/).length : 0);
|
||||
}, 0);
|
||||
@@ -68,7 +68,7 @@ export async function PUT(request: NextRequest) {
|
||||
return NextResponse.json({ error: 'Non autorisé' }, { status: 401 });
|
||||
}
|
||||
|
||||
const prisma = getDB();
|
||||
//const prisma = getDB();
|
||||
const body = await request.json();
|
||||
|
||||
const data: Record<string, unknown> = {};
|
||||
|
||||
@@ -11,28 +11,40 @@ const globalForPrisma = globalThis as unknown as {
|
||||
* Uses @prisma/adapter-pg with a pg Pool for direct PostgreSQL connections.
|
||||
*//*
|
||||
export function getDB(): PrismaClient {
|
||||
if (!globalForPrisma.prisma) {
|
||||
if (!globalForPrisma.prisma) {
|
||||
const connectionString = process.env.DATABASE_URL;
|
||||
const pool = new Pool({ connectionString });
|
||||
const adapter = new PrismaPg(pool);
|
||||
|
||||
globalForPrisma.prisma = new PrismaClient({ adapter });
|
||||
}
|
||||
return globalForPrisma.prisma;
|
||||
}
|
||||
return globalForPrisma.prisma;
|
||||
}
|
||||
|
||||
export default getDB;
|
||||
*/
|
||||
|
||||
import type { PrismaClient as PrismaClientType } from '@prisma/client';
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const globalForPrisma = globalThis as unknown as {
|
||||
prisma: PrismaClientType | undefined;
|
||||
prisma: PrismaClient | undefined;
|
||||
};
|
||||
|
||||
export const prisma = globalForPrisma.prisma ?? new PrismaClient();
|
||||
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;
|
||||
export function getDB(): PrismaClient {
|
||||
if (!globalForPrisma.prisma) {
|
||||
globalForPrisma.prisma = new PrismaClient();
|
||||
}
|
||||
return globalForPrisma.prisma;
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
globalForPrisma.prisma = getDB();
|
||||
}
|
||||
|
||||
export const prisma = new Proxy({} as any, {
|
||||
get(target, prop, receiver) {
|
||||
return Reflect.get(getDB(), prop, receiver);
|
||||
}
|
||||
}) as PrismaClient;
|
||||
|
||||
export function getDB() { return prisma; }
|
||||
export default getDB;
|
||||
Reference in New Issue
Block a user