Skip to content
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
7 changes: 6 additions & 1 deletion v2/dedup/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { log } from "console";
import { Request, Response, NextFunction } from "express";
const fs = require('fs');
const yaml = require('js-yaml');
Expand All @@ -14,7 +15,7 @@ export default function middleware(

// @ts-ignore
fs.access(filePath, fs.constants.F_OK, (err) => {
console.log(err ? 'File does not exist' : 'File exists');

if (err) {
// Create the file if it doesn't exist
fs.writeFileSync(filePath, '', 'utf-8');
Expand Down Expand Up @@ -56,6 +57,10 @@ export function afterMiddleware(req: Request, res: Response) {
}


if (!Array.isArray(existingData)) {
console.error('Expected an array for existingData, but got:', typeof existingData);
existingData = []; // Reset to an empty array or handle accordingly
}

// Add or update the entry for the current id
existingData.push(currentData);
Expand Down