mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
feat: support embedded authoring for creation (#1741)
Adds support for creating documents and templates using our embed components. Support is super primitive at the moment and is being polished.
This commit is contained in:
@ -0,0 +1,36 @@
|
||||
import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||
import { verifyEmbeddingPresignToken } from '@documenso/lib/server-only/embedding-presign/verify-embedding-presign-token';
|
||||
|
||||
import { procedure } from '../trpc';
|
||||
import {
|
||||
ZVerifyEmbeddingPresignTokenRequestSchema,
|
||||
ZVerifyEmbeddingPresignTokenResponseSchema,
|
||||
verifyEmbeddingPresignTokenMeta,
|
||||
} from './verify-embedding-presign-token.types';
|
||||
|
||||
/**
|
||||
* Public route.
|
||||
*/
|
||||
export const verifyEmbeddingPresignTokenRoute = procedure
|
||||
.meta(verifyEmbeddingPresignTokenMeta)
|
||||
.input(ZVerifyEmbeddingPresignTokenRequestSchema)
|
||||
.output(ZVerifyEmbeddingPresignTokenResponseSchema)
|
||||
.mutation(async ({ input }) => {
|
||||
try {
|
||||
const { token } = input;
|
||||
|
||||
const apiToken = await verifyEmbeddingPresignToken({
|
||||
token,
|
||||
}).catch(() => null);
|
||||
|
||||
return { success: !!apiToken };
|
||||
} catch (error) {
|
||||
if (error instanceof AppError) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
throw new AppError(AppErrorCode.UNKNOWN_ERROR, {
|
||||
message: 'Failed to verify embedding presign token',
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user