Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 02506d1

Browse filesBrowse files
committed
fix(isr): small fixes
1 parent 4be9998 commit 02506d1
Copy full SHA for 02506d1

File tree

5 files changed

+12
-22
lines changed
Filter options

5 files changed

+12
-22
lines changed

‎apps/docs/docs/isr/cache-hooks.md

Copy file name to clipboardExpand all lines: apps/docs/docs/isr/cache-hooks.md
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ server.get(
3333
},
3434
}),
3535

36-
// Server side render the page and add to cache if needed
3736
const isr = new ISRHandler({
3837
indexHtml,
3938
invalidateSecretToken: 'MY_TOKEN', // replace with env secret key ex. process.env.REVALIDATE_SECRET_TOKEN
@@ -48,7 +47,7 @@ server.get(
4847
// cache: fsCacheHandler,
4948
});
5049

51-
50+
// Server side render the page and add to cache if needed
5251
async (req, res, next) => await isr.render(req, res, next),
5352
);
5453
```

‎apps/ssr-isr/server.ts

Copy file name to clipboardExpand all lines: apps/ssr-isr/server.ts
+6-15Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { CommonEngine } from '@angular/ssr';
2-
import { modifyHtmlCallbackFn } from '@rx-angular/isr/models';
2+
import { ModifyHtmlCallbackFn } from '@rx-angular/isr/models';
33
import { ISRHandler } from '@rx-angular/isr/server';
44
import express, { Request } from 'express';
55
import { dirname, join, resolve } from 'node:path';
@@ -31,7 +31,7 @@ export function app(): express.Express {
3131
browserDistFolder,
3232
bootstrap,
3333
commonEngine,
34-
modifyGeneratedHtml: customModifyGeneratedHtml,
34+
modifyGeneratedHtml: defaultModifyGeneratedHtml,
3535
// cache: fsCacheHandler,
3636
});
3737

@@ -48,33 +48,24 @@ export function app(): express.Express {
4848
// Example Express Rest API endpoints
4949
// server.get('/api/**', (req, res) => { });
5050
// Serve static files from /browser
51-
server.get(
52-
'*.*',
53-
express.static(browserDistFolder, {
54-
maxAge: '1y',
55-
}),
56-
);
51+
server.get('*.*', express.static(browserDistFolder, { maxAge: '1y' }));
5752

5853
server.get(
5954
'*',
6055
// Serve page if it exists in cache
6156
async (req, res, next) => await isr.serveFromCache(req, res, next),
57+
6258
// Server side render the page and add to cache if needed
6359
async (req, res, next) =>
6460
await isr.render(req, res, next, {
65-
providers: [
66-
{
67-
provide: RESPONSE,
68-
useValue: res,
69-
},
70-
],
61+
providers: [{ provide: RESPONSE, useValue: res }],
7162
}),
7263
);
7364

7465
return server;
7566
}
7667

77-
const customModifyGeneratedHtml: modifyHtmlCallbackFn = (
68+
const defaultModifyGeneratedHtml: ModifyHtmlCallbackFn = (
7869
req: Request,
7970
html: string,
8071
revalidateTime?: number | null,

‎libs/isr/models/src/index.ts

Copy file name to clipboardExpand all lines: libs/isr/models/src/index.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export {
99
export {
1010
InvalidateConfig,
1111
ISRHandlerConfig,
12-
modifyHtmlCallbackFn,
12+
ModifyHtmlCallbackFn,
1313
RenderConfig,
1414
RouteISRConfig,
1515
ServeFromCacheConfig,

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

Copy file name to clipboardExpand all lines: libs/isr/models/src/isr-handler-config.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export interface ISRHandlerConfig {
112112
* If null, it will use `defaultModifyGeneratedHtml` function,
113113
* which only add commented text to the html to indicate when it was generated.
114114
*/
115-
modifyGeneratedHtml?: modifyHtmlCallbackFn;
115+
modifyGeneratedHtml?: ModifyHtmlCallbackFn;
116116
}
117117

118118
export interface ServeFromCacheConfig {
@@ -133,7 +133,7 @@ export interface InvalidateConfig {
133133
providers?: Provider[];
134134
}
135135

136-
export type modifyHtmlCallbackFn = (
136+
export type ModifyHtmlCallbackFn = (
137137
req: Request,
138138
html: string,
139139
revalidateTime?: number | null,

‎libs/isr/server/src/modify-generated-html.ts

Copy file name to clipboardExpand all lines: libs/isr/server/src/modify-generated-html.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { modifyHtmlCallbackFn } from '@rx-angular/isr/models';
21
import { Request } from 'express';
2+
import { ModifyHtmlCallbackFn } from '../../models/src';
33

4-
export const defaultModifyGeneratedHtml: modifyHtmlCallbackFn = (
4+
export const defaultModifyGeneratedHtml: ModifyHtmlCallbackFn = (
55
req: Request,
66
html: string,
77
revalidateTime?: number | null,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.