Skip to content

Commit ab8d41d

Browse files
authored
refactor(isr): clear tslint warning (#15)
1 parent 7528f7b commit ab8d41d

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

apps/ssr-isr/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export function app(): express.Express {
4141
modifyGeneratedHtml: customModifyGeneratedHtml,
4242
compressHtml: compressHtml, // compress the html before storing in cache
4343
logger: new customLogger(),
44+
renderingTimeoutMs: 5000, // 5 seconds timeout for rendering
4445
// cacheHtmlCompressionMethod: 'gzip', // compression method for cache
4546
// cache: fsCacheHandler,
4647
});

libs/isr/models/src/isr-handler-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export interface ISRHandlerConfig {
159159
* If the rendering takes longer than this timeout, the rendering will be stopped and an error will be thrown.
160160
* This is useful to prevent the server from hanging on a request that takes too long to render.
161161
**/
162-
renderingTimeoutMs: number | undefined;
162+
renderingTimeoutMs?: number | undefined;
163163
}
164164

165165
export interface ServeFromCacheConfig {

libs/isr/server/src/utils/render-url.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { CommonEngine } from '@angular/ssr';
22
import { Request, Response } from 'express';
3+
import { ILogger } from '../../../models/src/logger';
34
import { renderUrl, RenderUrlConfig } from './render-url';
45

56
jest.useFakeTimers();
@@ -8,7 +9,7 @@ describe('renderUrl - Timeout Test', () => {
89
let mockRequest: Request;
910
let mockResponse: Response;
1011
let mockCommonEngine: CommonEngine;
11-
let mockLogger: any;
12+
let mockLogger: ILogger;
1213

1314
beforeEach(() => {
1415
mockRequest = {
@@ -35,6 +36,8 @@ describe('renderUrl - Timeout Test', () => {
3536
mockLogger = {
3637
debug: jest.fn(),
3738
error: jest.fn(),
39+
info: jest.fn(),
40+
warn: jest.fn(),
3841
};
3942
});
4043

libs/isr/server/src/utils/render-url.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const renderUrl = async (options: RenderUrlConfig): Promise<string> => {
8383
logger?.debug(
8484
`done rendering url with common engine: ${html.substring(0, 200)}...`,
8585
);
86-
resolve(html as string);
86+
resolve(html);
8787
})
8888
.catch((err) => {
8989
logger?.error('Error: rendering url with common engine', err);

0 commit comments

Comments
 (0)