Skip to content

The Open Source DocuSign Alternative.

chore: update the contract to add deleteDocument route

Catalin Pit2ccede72eaea
diff --git a/packages/trpc/api-contract/contract.ts b/packages/trpc/api-contract/contract.ts
index 5357e67fa..2a002db45 100644
--- a/packages/trpc/api-contract/contract.ts
+++ b/packages/trpc/api-contract/contract.ts
@@ -3,7 +3,11 @@ import { z } from 'zod';
const c = initContract();
-const GetDocumentsQuery = z.object({
+/*
+ These schemas should be moved from here probably.
+ It grows quickly.
+*/
+const GetDocumentsQuerySchema = z.object({
page: z.string().optional(),
perPage: z.string().optional(),
});
@@ -19,19 +23,23 @@ const DocumentSchema = z.object({
completedAt: z.date().nullable(),
});
-const SuccessfulResponse = z.object({
+const SuccessfulResponseSchema = z.object({
documents: DocumentSchema.array(),
totalPages: z.number(),
});
+const UnsuccessfulResponseSchema = z.object({
+ message: z.string(),
+});
+
export const contract = c.router(
{
getDocuments: {
method: 'GET',
path: '/documents',
- query: GetDocumentsQuery,
+ query: GetDocumentsQuerySchema,
responses: {
- 200: SuccessfulResponse,
+ 200: SuccessfulResponseSchema,
},
summary: 'Get all documents',
},
@@ -43,6 +51,16 @@ export const contract = c.router(
},
summary: 'Get a single document',
},
+ deleteDocument: {
+ method: 'DELETE',
+ path: `/documents/:id`,
+ body: z.string(),
+ responses: {
+ 200: DocumentSchema,
+ 404: UnsuccessfulResponseSchema,
+ },
+ summary: 'Delete a document',
+ },
},
{
baseHeaders: z.object({