Skip to content

Commit

Permalink
fix(server): renderer path
Browse files Browse the repository at this point in the history
  • Loading branch information
forehalo committed Sep 19, 2024
1 parent 6921c30 commit 2b93bc2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
9 changes: 1 addition & 8 deletions .github/helm/affine/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,7 @@ spec:
name: affine-graphql
port:
number: {{ .Values.graphql.service.port }}
- path: /workspace/([^/]+)/(home|all|search|collection|tag|trash)
pathType: ImplementationSpecific
backend:
service:
name: affine-web
port:
number: {{ .Values.web.service.port }}
- path: /workspace/([^/]+)/.+
- path: /workspace/([^/]+)/([^/]+)$
pathType: ImplementationSpecific
backend:
service:
Expand Down
29 changes: 21 additions & 8 deletions packages/backend/server/src/core/doc-renderer/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ const defaultAssets: HtmlAssets = {
description: '',
};

// TODO(@forehalo): reuse routes with frontend
const staticPaths = new Set([
'all',
'home',
'search',
'collection',
'tag',
'trash',
]);

@Controller('/workspace')
export class DocRendererController {
private readonly logger = new Logger(DocRendererController.name);
Expand Down Expand Up @@ -84,14 +94,17 @@ export class DocRendererController {
: this.webAssets;

let opts: RenderOptions | null = null;
try {
opts =
workspaceId === docId
? await this.getWorkspaceContent(workspaceId)
: await this.getPageContent(workspaceId, docId);
metrics.doc.counter('render').add(1);
} catch (e) {
this.logger.error('failed to render page', e);

if (!staticPaths.has(docId)) {
try {
opts =
workspaceId === docId
? await this.getWorkspaceContent(workspaceId)
: await this.getPageContent(workspaceId, docId);
metrics.doc.counter('render').add(1);
} catch (e) {
this.logger.error('failed to render page', e);
}
}

res.setHeader('Content-Type', 'text/html');
Expand Down

0 comments on commit 2b93bc2

Please sign in to comment.