Skip to content

Commit

Permalink
fix: req per coverage for docker (#110)
Browse files Browse the repository at this point in the history
* refactor: add logs to debug

Signed-off-by: Sarthak Shyngle <[email protected]>

* refactor: add list check

Signed-off-by: Sarthak Shyngle <[email protected]>

* refactor: add log

Signed-off-by: Sarthak Shyngle <[email protected]>

* fix: req per coverage for docker

Signed-off-by: Sarthak Shyngle <[email protected]>

---------

Signed-off-by: Sarthak Shyngle <[email protected]>
  • Loading branch information
Sarthak160 authored May 13, 2024
1 parent bf86665 commit 37c90a3
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit 37c90a3

Please sign in to comment.