fix(server): use Query instead of Args (#12813)
#### PR Dependency Tree * **PR #12813** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal)
This commit is contained in:
@@ -36,6 +36,10 @@ test.beforeEach(async t => {
|
|||||||
workspace = await t.context.models.workspace.create(user.id);
|
workspace = await t.context.models.workspace.create(user.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test.afterEach.always(async () => {
|
||||||
|
mock.reset();
|
||||||
|
});
|
||||||
|
|
||||||
test.after.always(async t => {
|
test.after.always(async t => {
|
||||||
await t.context.app.close();
|
await t.context.app.close();
|
||||||
});
|
});
|
||||||
@@ -176,6 +180,15 @@ test('should get doc content in json format', async t => {
|
|||||||
summary: 'test summary',
|
summary: 'test summary',
|
||||||
})
|
})
|
||||||
.expect(200);
|
.expect(200);
|
||||||
|
|
||||||
|
await app
|
||||||
|
.GET(`/rpc/workspaces/${workspace.id}/docs/${docId}/content?full=false`)
|
||||||
|
.set('x-access-token', t.context.crypto.sign(docId))
|
||||||
|
.expect({
|
||||||
|
title: 'test title',
|
||||||
|
summary: 'test summary',
|
||||||
|
})
|
||||||
|
.expect(200);
|
||||||
t.pass();
|
t.pass();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -184,7 +197,7 @@ test('should get full doc content in json format', async t => {
|
|||||||
mock.method(t.context.databaseDocReader, 'getFullDocContent', async () => {
|
mock.method(t.context.databaseDocReader, 'getFullDocContent', async () => {
|
||||||
return {
|
return {
|
||||||
title: 'test title',
|
title: 'test title',
|
||||||
summary: 'test summary',
|
summary: 'test summary full',
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -194,7 +207,7 @@ test('should get full doc content in json format', async t => {
|
|||||||
.set('x-access-token', t.context.crypto.sign(docId))
|
.set('x-access-token', t.context.crypto.sign(docId))
|
||||||
.expect({
|
.expect({
|
||||||
title: 'test title',
|
title: 'test title',
|
||||||
summary: 'test summary',
|
summary: 'test summary full',
|
||||||
})
|
})
|
||||||
.expect(200);
|
.expect(200);
|
||||||
t.pass();
|
t.pass();
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import {
|
|||||||
Logger,
|
Logger,
|
||||||
Param,
|
Param,
|
||||||
Post,
|
Post,
|
||||||
|
Query,
|
||||||
RawBody,
|
RawBody,
|
||||||
Res,
|
Res,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { Args } from '@nestjs/graphql';
|
|
||||||
import type { Response } from 'express';
|
import type { Response } from 'express';
|
||||||
|
|
||||||
import { NotFound, SkipThrottle } from '../../base';
|
import { NotFound, SkipThrottle } from '../../base';
|
||||||
@@ -78,11 +78,12 @@ export class DocRpcController {
|
|||||||
async getDocContent(
|
async getDocContent(
|
||||||
@Param('workspaceId') workspaceId: string,
|
@Param('workspaceId') workspaceId: string,
|
||||||
@Param('docId') docId: string,
|
@Param('docId') docId: string,
|
||||||
@Args('full', { nullable: true }) fullContent?: boolean
|
@Query('full') fullContent?: string
|
||||||
) {
|
) {
|
||||||
const content = fullContent
|
const content =
|
||||||
? await this.docReader.getFullDocContent(workspaceId, docId)
|
fullContent === 'true'
|
||||||
: await this.docReader.getDocContent(workspaceId, docId);
|
? await this.docReader.getFullDocContent(workspaceId, docId)
|
||||||
|
: await this.docReader.getDocContent(workspaceId, docId);
|
||||||
if (!content) {
|
if (!content) {
|
||||||
throw new NotFound('Doc not found');
|
throw new NotFound('Doc not found');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user