mirror of
https://github.com/documenso/documenso.git
synced 2025-11-11 04:52:41 +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 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(),
|
page: z.string().optional(),
|
||||||
perPage: z.string().optional(),
|
perPage: z.string().optional(),
|
||||||
});
|
});
|
||||||
@ -19,19 +23,23 @@ const DocumentSchema = z.object({
|
|||||||
completedAt: z.date().nullable(),
|
completedAt: z.date().nullable(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const SuccessfulResponse = z.object({
|
const SuccessfulResponseSchema = z.object({
|
||||||
documents: DocumentSchema.array(),
|
documents: DocumentSchema.array(),
|
||||||
totalPages: z.number(),
|
totalPages: z.number(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const UnsuccessfulResponseSchema = z.object({
|
||||||
|
message: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
export const contract = c.router(
|
export const contract = c.router(
|
||||||
{
|
{
|
||||||
getDocuments: {
|
getDocuments: {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
path: '/documents',
|
path: '/documents',
|
||||||
query: GetDocumentsQuery,
|
query: GetDocumentsQuerySchema,
|
||||||
responses: {
|
responses: {
|
||||||
200: SuccessfulResponse,
|
200: SuccessfulResponseSchema,
|
||||||
},
|
},
|
||||||
summary: 'Get all documents',
|
summary: 'Get all documents',
|
||||||
},
|
},
|
||||||
@ -43,6 +51,16 @@ export const contract = c.router(
|
|||||||
},
|
},
|
||||||
summary: 'Get a single document',
|
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({
|
baseHeaders: z.object({
|
||||||
|
|||||||
Reference in New Issue
Block a user