Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update body parser #622

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading