@@ -89,7 +89,7 @@ export class FileSystemCacheHandler extends CacheHandler {
89
89
} )
90
90
. catch ( ( err ) => {
91
91
reject (
92
- `Error: 💥 Cannot read cache file for route ${ cacheKey } : ${ cachedMeta . htmlFilePath } , ${ err } ` ,
92
+ `Error: 💥 Cannot read cache file for cacheKey ${ cacheKey } : ${ cachedMeta . htmlFilePath } , ${ err } ` ,
93
93
) ;
94
94
} ) ;
95
95
} else {
@@ -104,23 +104,23 @@ export class FileSystemCacheHandler extends CacheHandler {
104
104
105
105
delete ( cacheKey : string ) : Promise < boolean > {
106
106
return new Promise ( ( resolve , reject ) => {
107
- const cacheMeta = this . cache . get ( cacheKey ) ;
107
+ const cachedMeta = this . cache . get ( cacheKey ) ;
108
108
109
- if ( cacheMeta ) {
110
- fs . unlink ( cacheMeta . htmlFilePath , ( err ) => {
109
+ if ( cachedMeta ) {
110
+ fs . unlink ( cachedMeta . htmlFilePath , ( err ) => {
111
111
if ( err ) {
112
112
reject (
113
- 'Error: 💥 Cannot delete cache file for route ' +
113
+ 'Error: 💥 Cannot delete cache file for cacheKey ' +
114
114
cacheKey +
115
- `: ${ cacheMeta . htmlFilePath } ` ,
115
+ `: ${ cachedMeta . htmlFilePath } ` ,
116
116
) ;
117
117
} else {
118
118
this . cache . delete ( cacheKey ) ;
119
119
resolve ( true ) ;
120
120
}
121
121
} ) ;
122
122
} else {
123
- reject ( `Error: 💥 CacheKey : ${ cacheKey } is not cached.` ) ;
123
+ reject ( `Error: 💥 cacheKey : ${ cacheKey } is not cached.` ) ;
124
124
}
125
125
} ) ;
126
126
}
@@ -184,7 +184,7 @@ export class FileSystemCacheHandler extends CacheHandler {
184
184
isBuffer : false ,
185
185
} ) ;
186
186
187
- console . log ( 'The request was stored in cache! Route : ' , cacheKey ) ;
187
+ console . log ( 'The request was stored in cache! cacheKey : ' , cacheKey ) ;
188
188
}
189
189
}
190
190
@@ -222,7 +222,9 @@ export class FileSystemCacheHandler extends CacheHandler {
222
222
}
223
223
}
224
224
} catch ( err ) {
225
- console . error ( 'ERROR! 💥 ! Cannot read folder: ' + folderPath ) ;
225
+ console . error (
226
+ `ERROR! 💥 ! Cannot read folder: ${ folderPath } , err: ${ err instanceof Error ? err . message : '' } ` ,
227
+ ) ;
226
228
}
227
229
228
230
for ( const { path } of pathsToCache ) {
@@ -316,7 +318,9 @@ function findIndexHtmlFilesRecursively(
316
318
} ) ;
317
319
} catch ( err ) {
318
320
// If an error occurs, log an error message and return an empty array
319
- console . error ( 'ERROR! 💥 ! Cannot read folder: ' + path ) ;
321
+ console . error (
322
+ `ERROR! 💥 ! Cannot read folder: ${ path } , err: ${ err instanceof Error ? err . message : '' } ` ,
323
+ ) ;
320
324
return [ ] ;
321
325
}
322
326
@@ -345,22 +349,22 @@ function getFileFullPath(fileName: string, cacheFolderPath: string): string {
345
349
}
346
350
347
351
/**
348
- * This function takes a string parameter 'route ' and replaces all '/' characters in it with '__' and returns the modified string.
352
+ * This function takes a string parameter 'cacheKey ' and replaces all '/' characters in it with '__' and returns the modified string.
349
353
*
350
354
* @internal
351
- * @param {string } cacheKey - The string representing the route to be converted into a file name.
355
+ * @param {string } cacheKey - The string representing the cacheKey to be converted into a file name.
352
356
* @returns {string } The modified string representing the file name obtained by replacing '/' characters with '__'.
353
357
*/
354
358
export function convertCacheKeyToFileName ( cacheKey : string ) : string {
355
- // replace all occurrences of '/' character in the 'route ' string with '__' using regular expression
359
+ // replace all occurrences of '/' character in the 'cacheKey ' string with '__' using regular expression
356
360
return cacheKey
357
361
. replace ( new RegExp ( '/' , 'g' ) , '__' )
358
362
. replace ( new RegExp ( '\\?' , 'g' ) , '++' ) ;
359
363
}
360
364
361
365
/**
362
366
* This function takes a string parameter 'fileName' and replaces all '__' strings in it with '/' and returns the modified string.
363
- * @param fileName - The string representing the file name to be converted into a route .
367
+ * @param fileName - The string representing the file name to be converted into a cacheKey .
364
368
*/
365
369
export function convertFileNameToCacheKey ( fileName : string ) : string {
366
370
// replace all occurrences of '__' string in the 'fileName' string with '/' using regular expression
0 commit comments