chore(server): enable renderer for all deployment (#8283)

This commit is contained in:
forehalo 2024-09-19 02:34:57 +00:00
parent a1fe7c8ef6
commit 03ac9bc4a1
No known key found for this signature in database
GPG Key ID: 56709255DC7EC728
2 changed files with 14 additions and 9 deletions

View File

@ -60,15 +60,20 @@ spec:
name: affine-graphql
port:
number: {{ .Values.graphql.service.port }}
{{- if eq .Values.global.app.buildType "canary" }}
- path: /workspace
pathType: Prefix
- path: /workspace/([^/]+)/(home|all|search|collection|tag|trash)
pathType: ImplementationSpecific
backend:
service:
name: affine-web
port:
number: {{ .Values.web.service.port }}
- path: /workspace/([^/]+)/.+
pathType: ImplementationSpecific
backend:
service:
name: affine-renderer
port:
number: {{ .Values.graphql.service.port }}
{{- end }}
number: {{ .Values.renderer.service.port }}
- path: /
pathType: Prefix
backend:

View File

@ -33,7 +33,7 @@ const defaultAssets: HtmlAssets = {
description: '',
};
@Controller('/workspace/:workspaceId/:docId')
@Controller('/workspace')
export class DocRendererController {
private readonly logger = new Logger(DocRendererController.name);
private readonly webAssets: HtmlAssets = defaultAssets;
@ -68,7 +68,7 @@ export class DocRendererController {
}
@Public()
@Get()
@Get('/:workspaceId/:docId')
async render(
@Req() req: Request,
@Res() res: Response,
@ -87,7 +87,7 @@ export class DocRendererController {
try {
opts =
workspaceId === docId
? await this.renderWorkspace(workspaceId)
? await this.getWorkspaceContent(workspaceId)
: await this.getPageContent(workspaceId, docId);
metrics.doc.counter('render').add(1);
} catch (e) {
@ -123,7 +123,7 @@ export class DocRendererController {
return null;
}
private async renderWorkspace(
private async getWorkspaceContent(
workspaceId: string
): Promise<RenderOptions | null> {
const allowUrlPreview = await this.permission.allowUrlPreview(workspaceId);