Skip to content

Commit

Permalink
missing clients to remove
Browse files Browse the repository at this point in the history
  • Loading branch information
matmut7 committed Oct 10, 2024
1 parent 4564c28 commit be02016
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/pages/api/commissions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const get: NextApiHandler = async (req, res) => {
? await getUpcomingCommissionsNotEmpty(req)
: await getUpcomingCommissions()
: await getUpcomingCommissionsByDepartement(departements as string);
await client?.$disconnect()
res.status(200).json(superjson.stringify(commissions));
};

Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/dossiers/[id].ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import type { TransitionEvent } from "src/lib/statutDossierStateMachine";
import { factory as statutDossierStateMachineFactory } from "src/lib/statutDossierStateMachine";
import superjson from "superjson";

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

const handler: NextApiHandler = async (req, res) => {
const session = await getSession({ req });
Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/sync/inc/dossiers/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { withSentry } from "@sentry/nextjs";
import type { NextApiHandler, NextApiRequest } from "next";

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

const handler: NextApiHandler = async (req, res) => {
if (req.method === "GET") {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/api/sync/inc/dossiers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {
import { frenchDateText, frenchDepartementName } from "src/lib/helpers";
import type { z } from "zod";

import { PrismaClient, Prisma } from "@prisma/client";
const client = new PrismaClient({ log: ["query", "info", "warn", "error"] });
import { client } from "src/lib/prismaClient";

export const config = {
api: {
Expand Down
7 changes: 2 additions & 5 deletions src/pages/api/users/id/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { NextApiHandler } from "next";
import { PrismaClient, User } from "@prisma/client";
import { client } from "src/lib/prismaClient";
import { getSession } from "next-auth/react";

const handler: NextApiHandler = async (req, res) => {
Expand All @@ -17,7 +17,6 @@ const handler: NextApiHandler = async (req, res) => {
};

const getUserById: NextApiHandler = async (req, res) => {
const prisma = new PrismaClient();
let userIds: number[] | number = [];

if (req.query.id) {
Expand All @@ -30,17 +29,15 @@ const getUserById: NextApiHandler = async (req, res) => {
}
}
try {
const users = await prisma.user.findMany({
const users = await client.user.findMany({
where: {
id: {
in: userIds,
},
},
});
await prisma?.$disconnect();
res.status(200).json(users);
} catch (e: unknown) {
await prisma?.$disconnect();
console.log(e);
}
};
Expand Down

0 comments on commit be02016

Please sign in to comment.