mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
feat: public api start
This commit is contained in:
32
packages/trpc/api-contract/contract.ts
Normal file
32
packages/trpc/api-contract/contract.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { initContract } from '@ts-rest/core';
|
||||
import { z } from 'zod';
|
||||
|
||||
const c = initContract();
|
||||
|
||||
const GetDocumentsQuery = z.object({
|
||||
take: z.string().default('10'),
|
||||
skip: z.string().default('0'),
|
||||
});
|
||||
|
||||
const DocumentSchema = z.object({
|
||||
id: z.string(),
|
||||
userId: z.number(),
|
||||
title: z.string(),
|
||||
status: z.string(),
|
||||
documentDataId: z.string(),
|
||||
createdAt: z.string(),
|
||||
updatedAt: z.string(),
|
||||
completedAt: z.string(),
|
||||
});
|
||||
|
||||
export const contract = c.router({
|
||||
getDocuments: {
|
||||
method: 'GET',
|
||||
path: '/documents',
|
||||
query: GetDocumentsQuery,
|
||||
responses: {
|
||||
200: DocumentSchema.array(),
|
||||
},
|
||||
summary: 'Get all documents for a user',
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user