mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
chore: update the contract to add deleteDocument route
This commit is contained in:
@ -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({
|
||||
|
||||
Reference in New Issue
Block a user