feat: public api start

This commit is contained in:
Catalin Pit
2023-11-22 15:03:15 +02:00
parent 9444e0cc67
commit 24d9906557
4 changed files with 264 additions and 1 deletions

View 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',
},
});

View File

@ -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"
}

View File

@ -1,5 +1,8 @@
{
"extends": "@documenso/tsconfig/react-library.json",
"include": ["."],
"exclude": ["dist", "build", "node_modules"]
"exclude": ["dist", "build", "node_modules"],
"compilerOptions": {
"strict": true,
}
}