Skip to content

Commit 37c90a3

Browse files
authored
fix: req per coverage for docker (#110)
* refactor: add logs to debug Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com> * refactor: add list check Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com> * refactor: add log Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com> * fix: req per coverage for docker Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com> --------- Signed-off-by: Sarthak Shyngle <50234097+Sarthak160@users.noreply.github.com>
1 parent bf86665 commit 37c90a3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

v2/dedup/middleware.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
import { log } from "console";
23
import { Request, Response, NextFunction } from "express";
34
const fs = require('fs');
45
const yaml = require('js-yaml');
@@ -14,7 +15,7 @@ export default function middleware(
1415

1516
// @ts-ignore
1617
fs.access(filePath, fs.constants.F_OK, (err) => {
17-
console.log(err ? 'File does not exist' : 'File exists');
18+
1819
if (err) {
1920
// Create the file if it doesn't exist
2021
fs.writeFileSync(filePath, '', 'utf-8');
@@ -56,6 +57,10 @@ export function afterMiddleware(req: Request, res: Response) {
5657
}
5758

5859

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

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

0 commit comments

Comments
 (0)