@dakkitor/api-contracts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -0
- package/dist/clients/clients.contract.d.ts +1515 -0
- package/dist/clients/clients.contract.d.ts.map +1 -0
- package/dist/clients/clients.contract.js +181 -0
- package/dist/common/error-schemas.d.ts +32 -0
- package/dist/common/error-schemas.d.ts.map +1 -0
- package/dist/common/error-schemas.js +17 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @dakkitor/api-contracts
|
|
2
|
+
|
|
3
|
+
TypeScript API contracts using ts-rest and Zod.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @dakkitor/api-contracts
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Backend (NestJS + ts-rest)
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { clientsContract } from '@dakkitor/api-contracts';
|
|
17
|
+
import { tsRestHandler } from '@ts-rest/nest';
|
|
18
|
+
|
|
19
|
+
@TsRestHandler(clientsContract.create)
|
|
20
|
+
async create() {
|
|
21
|
+
return tsRestHandler(clientsContract.create, async ({ body }) => {
|
|
22
|
+
// Your implementation
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Frontend (React/Next.js)
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { clientsContract } from '@dakkitor/api-contracts';
|
|
31
|
+
import { initClient } from '@ts-rest/core';
|
|
32
|
+
|
|
33
|
+
const client = initClient(clientsContract, {
|
|
34
|
+
baseUrl: 'https://api.example.com',
|
|
35
|
+
baseHeaders: {},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Type-safe API calls
|
|
39
|
+
const result = await client.create({ body: { name: 'Acme Corp' } });
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## What's Included
|
|
43
|
+
|
|
44
|
+
- **Client Contracts**: Full CRUD operations for clients module
|
|
45
|
+
- **Error Schemas**: Standardized error response types matching `IErrorResponse`
|
|
46
|
+
- **Type Safety**: Full TypeScript support with Zod validation
|
|
47
|
+
|
|
48
|
+
## Requirements
|
|
49
|
+
|
|
50
|
+
This package has peer dependencies:
|
|
51
|
+
|
|
52
|
+
- `@ts-rest/core` ^3.30.0
|
|
53
|
+
- `zod` ^3.22.0
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|