mirror of
https://github.com/documenso/documenso.git
synced 2026-06-22 04:12:06 +10:00
bc184d445f
Uploaded .docx files are converted to PDF on the server using a Gotenberg sidecar before entering the normal envelope pipeline. The feature is opt-in via NEXT_PRIVATE_DOCUMENT_CONVERSION_URL; when unset, only PDF uploads are accepted. A per-process circuit breaker opens for 30s after a conversion failure to shed load. Ships a dev Dockerfile that layers Microsoft Core Fonts and additional language fonts onto the upstream Gotenberg image for better fidelity. Co-authored-by: Ephraim Duncan <55143799+ephraimduncan@users.noreply.github.com> Co-authored-by: Ephraim Duncan <55143799+ephraimduncan@users.noreply.github.com>
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
|
import { verifyEmbeddingPresignToken } from '@documenso/lib/server-only/embedding-presign/verify-embedding-presign-token';
|
|
|
|
import { createEnvelopeRouteCaller } from '../envelope-router/create-envelope';
|
|
import { procedure } from '../trpc';
|
|
import {
|
|
ZCreateEmbeddingEnvelopeRequestSchema,
|
|
ZCreateEmbeddingEnvelopeResponseSchema,
|
|
} from './create-embedding-envelope.types';
|
|
|
|
export const createEmbeddingEnvelopeRoute = procedure
|
|
.input(ZCreateEmbeddingEnvelopeRequestSchema)
|
|
.output(ZCreateEmbeddingEnvelopeResponseSchema)
|
|
.mutation(async ({ input, ctx }) => {
|
|
const { req } = ctx;
|
|
|
|
const authorizationHeader = req.headers.get('authorization');
|
|
|
|
const [presignToken] = (authorizationHeader || '').split('Bearer ').filter((s) => s.length > 0);
|
|
|
|
if (!presignToken) {
|
|
throw new AppError(AppErrorCode.UNAUTHORIZED, {
|
|
message: 'No presign token provided',
|
|
});
|
|
}
|
|
|
|
const apiToken = await verifyEmbeddingPresignToken({ token: presignToken });
|
|
|
|
const { userId, teamId } = apiToken;
|
|
|
|
return await createEnvelopeRouteCaller({
|
|
userId,
|
|
teamId,
|
|
input,
|
|
options: {
|
|
// Default recipients should be added on the frontend automatically for embeds.
|
|
bypassDefaultRecipients: true,
|
|
},
|
|
apiRequestMetadata: ctx.metadata,
|
|
logger: ctx.logger,
|
|
});
|
|
});
|