fix: 完善本地与网络图片渲染
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
"typecheck": "tsc -p tsconfig.json --noEmit --pretty false"
|
||||
},
|
||||
"dependencies": {
|
||||
"@md-to-pdf/application": "0.4.0",
|
||||
"@md-to-pdf/application": "0.4.1",
|
||||
"@md-to-pdf/core": "0.1.0",
|
||||
"@md-to-pdf/renderer": "0.1.0",
|
||||
"fastify": "^5.6.2",
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
interface RenderRequestBody {
|
||||
markdown?: unknown;
|
||||
language?: unknown;
|
||||
resources?: unknown;
|
||||
}
|
||||
|
||||
interface PdfRequestBody extends RenderRequestBody {
|
||||
@@ -108,7 +109,7 @@ function createPdfServerTiming(
|
||||
export function buildApp(options: BuildAppOptions = {}) {
|
||||
const app = Fastify({
|
||||
logger: options.logger ?? true,
|
||||
bodyLimit: 2 * 1024 * 1024
|
||||
bodyLimit: 24 * 1024 * 1024
|
||||
});
|
||||
const applicationService =
|
||||
options.applicationService ??
|
||||
@@ -214,7 +215,7 @@ export function buildApp(options: BuildAppOptions = {}) {
|
||||
"/api/render",
|
||||
async (request, reply) => {
|
||||
try {
|
||||
return applicationService.render(request.body ?? {});
|
||||
return await applicationService.render(request.body ?? {});
|
||||
} catch (error) {
|
||||
if (error instanceof ApplicationRequestError) {
|
||||
return reply.code(error.statusCode).send({
|
||||
@@ -267,7 +268,7 @@ export function buildApp(options: BuildAppOptions = {}) {
|
||||
const markdownStartedAt = performance.now();
|
||||
let rendered;
|
||||
try {
|
||||
rendered = applicationService.render(request.body ?? {});
|
||||
rendered = await applicationService.render(request.body ?? {});
|
||||
} catch (error) {
|
||||
if (error instanceof ApplicationRequestError) {
|
||||
return reply.code(error.statusCode).send({
|
||||
|
||||
Reference in New Issue
Block a user