mirror of
https://github.com/documenso/documenso.git
synced 2025-11-18 02:32:00 +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',
|
||||
},
|
||||
});
|
||||
@ -17,6 +17,8 @@
|
||||
"@trpc/next": "^10.36.0",
|
||||
"@trpc/react-query": "^10.36.0",
|
||||
"@trpc/server": "^10.36.0",
|
||||
"@ts-rest/core": "^3.30.5",
|
||||
"@ts-rest/next": "^3.30.5",
|
||||
"superjson": "^1.13.1",
|
||||
"zod": "^3.22.4"
|
||||
}
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
{
|
||||
"extends": "@documenso/tsconfig/react-library.json",
|
||||
"include": ["."],
|
||||
"exclude": ["dist", "build", "node_modules"]
|
||||
"exclude": ["dist", "build", "node_modules"],
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user