File tree 1 file changed +6
-1
lines changed
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 1
1
/* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { log } from "console" ;
2
3
import { Request , Response , NextFunction } from "express" ;
3
4
const fs = require ( 'fs' ) ;
4
5
const yaml = require ( 'js-yaml' ) ;
@@ -14,7 +15,7 @@ export default function middleware(
14
15
15
16
// @ts -ignore
16
17
fs . access ( filePath , fs . constants . F_OK , ( err ) => {
17
- console . log ( err ? 'File does not exist' : 'File exists' ) ;
18
+
18
19
if ( err ) {
19
20
// Create the file if it doesn't exist
20
21
fs . writeFileSync ( filePath , '' , 'utf-8' ) ;
@@ -56,6 +57,10 @@ export function afterMiddleware(req: Request, res: Response) {
56
57
}
57
58
58
59
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
+ }
59
64
60
65
// Add or update the entry for the current id
61
66
existingData . push ( currentData ) ;
You can’t perform that action at this time.
0 commit comments