mirror of
https://github.com/documenso/documenso.git
synced 2026-07-25 01:15:49 +10:00
fix: refactor document router (#1990)
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { deleteDocument } from '@documenso/lib/server-only/document/delete-document';
|
||||
|
||||
import { authenticatedProcedure } from '../trpc';
|
||||
import {
|
||||
ZDeleteDocumentRequestSchema,
|
||||
ZDeleteDocumentResponseSchema,
|
||||
deleteDocumentMeta,
|
||||
} from './delete-document.types';
|
||||
import { ZGenericSuccessResponse } from './schema';
|
||||
|
||||
export const deleteDocumentRoute = authenticatedProcedure
|
||||
.meta(deleteDocumentMeta)
|
||||
.input(ZDeleteDocumentRequestSchema)
|
||||
.output(ZDeleteDocumentResponseSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
const { teamId } = ctx;
|
||||
const { documentId } = input;
|
||||
|
||||
ctx.logger.info({
|
||||
input: {
|
||||
documentId,
|
||||
},
|
||||
});
|
||||
|
||||
const userId = ctx.user.id;
|
||||
|
||||
await deleteDocument({
|
||||
id: documentId,
|
||||
userId,
|
||||
teamId,
|
||||
requestMetadata: ctx.metadata,
|
||||
});
|
||||
|
||||
return ZGenericSuccessResponse;
|
||||
});
|
||||
Reference in New Issue
Block a user