good presidio

This commit is contained in:
nBiqoz
2025-06-18 14:57:11 +02:00
parent c4dbf3df96
commit bdbc126b11
5 changed files with 907 additions and 104 deletions

View File

@@ -1,5 +1,5 @@
import { NextResponse, type NextRequest } from "next/server"; import { NextResponse, type NextRequest } from "next/server";
import pdf from "pdf-parse"; import pdf from "pdf-parse/lib/pdf-parse";
import mammoth from "mammoth"; import mammoth from "mammoth";
export async function POST(req: NextRequest) { export async function POST(req: NextRequest) {

View File

@@ -1,4 +1,44 @@
/** @type {import('next').NextConfig} */ // next.config.ts
const nextConfig = {};
module.exports = nextConfig; import { type NextConfig } from "next";
import { type Configuration } from "webpack";
/** @type {import('next').NextConfig} */
const nextConfig: NextConfig = {
// ... autres configurations
webpack: (config: Configuration, { isServer }: { isServer: boolean }) => {
// ---- DÉBUT DE LA CORRECTION ----
// Récupère les externals existants, en initialisant un tableau vide si non défini.
const existingExternals = config.externals || [];
// Remplace la configuration externals par un nouveau tableau.
// Ce tableau contient :
// 1. Les externals existants (s'ils étaient déjà un tableau, on les déverse, sinon on les met dans un tableau).
// 2. Notre nouvel external pour 'fs'.
config.externals = [
...(Array.isArray(existingExternals)
? existingExternals
: [existingExternals]),
{ fs: "fs" }, // On indique de ne pas bundler 'fs'
];
// ---- FIN DE LA CORRECTION ----
// Côté client (navigateur), on ne veut pas du tout du module 'fs'.
if (!isServer) {
if (!config.resolve) {
config.resolve = {};
}
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
};
}
return config;
},
};
export default nextConfig;

931
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -38,6 +38,7 @@
"@types/pdfjs-dist": "^2.10.377", "@types/pdfjs-dist": "^2.10.377",
"@types/react": "^19", "@types/react": "^19",
"@types/react-dom": "^19", "@types/react-dom": "^19",
"@types/webpack": "^5.28.5",
"eslint": "^9", "eslint": "^9",
"eslint-config-next": "15.3.3", "eslint-config-next": "15.3.3",
"tailwindcss": "^4", "tailwindcss": "^4",

31
types/pdf-parse.d.ts vendored Normal file
View File

@@ -0,0 +1,31 @@
// types/pdf-parse.d.ts
declare module "pdf-parse/lib/pdf-parse" {
interface PDFInfo {
PDFFormatVersion?: string;
IsAcroFormPresent?: boolean;
IsXFAPresent?: boolean;
Title?: string;
Author?: string;
Subject?: string;
Creator?: string;
Producer?: string;
CreationDate?: Date;
ModDate?: Date;
}
interface PDFMetadata {
[key: string]: string | number | Date | undefined;
}
interface PDFData {
numpages: number;
numrender: number;
info: PDFInfo;
metadata: PDFMetadata;
version: string;
text: string;
}
function pdfParse(buffer: Buffer): Promise<PDFData>;
export default pdfParse;
}