Skip to content

Commit

Permalink
fix: update body parser
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannNumericite committed Jun 11, 2024
1 parent eb1122b commit a78532f
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions src/pages/api/sync/inc/dossiers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ import {
import { frenchDateText, frenchDepartementName } from "src/lib/helpers";
import type { z } from "zod";

import { PrismaClient, Prisma } from '@prisma/client'
const client = new PrismaClient()
import { PrismaClient, Prisma } from "@prisma/client";
const client = new PrismaClient();

export const config = {
api: {
bodyParser: {
sizeLimit: "5mb",
},
},
};

const handler: NextApiHandler = async (req, res) => {
if (req.method == "POST") {
Expand Down Expand Up @@ -188,7 +196,7 @@ const update: NextApiHandler = async (req, res) => {
enfants: z.infer<typeof RelatedEnfantModel>[];
};

console.log('UPDATING DOSSIER : ', data.dossier.nom, ', ', data.dossier.id)
console.log("UPDATING DOSSIER : ", data.dossier.nom, ", ", data.dossier.id);

try {
const commissions = await client.commission.findMany({
Expand Down Expand Up @@ -236,7 +244,7 @@ const update: NextApiHandler = async (req, res) => {
adresseEnfant: true,
cdc: true,
dossierId: true,
id: true
id: true,
});
data.enfants.map(async (enfant) => {
enfant.nombreJours =
Expand Down Expand Up @@ -279,7 +287,14 @@ const update: NextApiHandler = async (req, res) => {
// console.log("enfant updated :", updateEnfant.externalId);
} else {
try {
console.log("has to create enfant :", enfant.nom, ' ', enfant.prenom, ', ', enfant.id);
console.log(
"has to create enfant :",
enfant.nom,
" ",
enfant.prenom,
", ",
enfant.id
);
const CreateEnfants = await client.enfant.create({
data: {
...EnfantsData.parse(enfant),
Expand All @@ -292,7 +307,7 @@ const update: NextApiHandler = async (req, res) => {
});
// console.log("enfant updated :", CreateEnfants.externalId);
} catch (e) {
console.log('PROBLEM with : ', enfant.id)
console.log("PROBLEM with : ", enfant.id);
}
}
});
Expand Down

0 comments on commit a78532f

Please # to comment.