@codexsploitx/schemaapi 1.0.4 → 1.0.5
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/bin/schemaapi +10 -2
- package/package.json +1 -1
- package/readme.md +40 -30
package/bin/schemaapi
CHANGED
|
@@ -23,6 +23,14 @@ function showHelp() {
|
|
|
23
23
|
console.log(" schemaapi generate tests");
|
|
24
24
|
console.log(" schemaapi audit");
|
|
25
25
|
console.log(" schemaapi init <adapter>");
|
|
26
|
+
console.log("");
|
|
27
|
+
console.log("Adapters:");
|
|
28
|
+
console.log(" express");
|
|
29
|
+
console.log(" next");
|
|
30
|
+
console.log(" fastify");
|
|
31
|
+
console.log(" remix");
|
|
32
|
+
console.log(" nest");
|
|
33
|
+
console.log(" deno");
|
|
26
34
|
}
|
|
27
35
|
|
|
28
36
|
function loadConfig() {
|
|
@@ -228,7 +236,7 @@ function handleInit(adapterArg) {
|
|
|
228
236
|
const usersContractPath = path.join(contractsDir, "usersContract.ts");
|
|
229
237
|
if (!fs.existsSync(usersContractPath)) {
|
|
230
238
|
const usersContractContent = [
|
|
231
|
-
'import { createContract } from "schemaapi";',
|
|
239
|
+
'import { createContract } from "@codexsploitx/schemaapi";',
|
|
232
240
|
'import { z } from "zod";',
|
|
233
241
|
"",
|
|
234
242
|
"export const usersContract = createContract({",
|
|
@@ -257,7 +265,7 @@ function handleInit(adapterArg) {
|
|
|
257
265
|
const routePath = path.join(appApiUsersDir, "route.ts");
|
|
258
266
|
if (!fs.existsSync(routePath)) {
|
|
259
267
|
const nextRouteContent = [
|
|
260
|
-
'import { adapters } from "schemaapi";',
|
|
268
|
+
'import { adapters } from "@codexsploitx/schemaapi";',
|
|
261
269
|
'import { usersContract } from "../../../contracts";',
|
|
262
270
|
"",
|
|
263
271
|
"const handlers = adapters.next.handleContract(usersContract, {",
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
**The Zod of APIs**
|
|
6
6
|
*Type-safe contracts. Runtime validation. Auto-generated docs.*
|
|
7
7
|
|
|
8
|
-
[](https://www.npmjs.com/package/@codexsploitx/schemaapi)
|
|
9
|
+
[](LICENSE)
|
|
10
10
|
[](https://github.com/CodexSploitx/SchemaApi/actions)
|
|
11
11
|
[](https://www.typescriptlang.org/)
|
|
12
12
|
|
|
@@ -49,19 +49,30 @@
|
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
51
|
# npm
|
|
52
|
-
npm install schemaapi zod
|
|
52
|
+
npm install @codexsploitx/schemaapi zod
|
|
53
53
|
|
|
54
54
|
# pnpm
|
|
55
|
-
pnpm add schemaapi zod
|
|
55
|
+
pnpm add @codexsploitx/schemaapi zod
|
|
56
56
|
|
|
57
57
|
# yarn
|
|
58
|
-
yarn add schemaapi zod
|
|
58
|
+
yarn add @codexsploitx/schemaapi zod
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
### Per-adapter setup
|
|
62
62
|
|
|
63
63
|
Below are the recommended commands for **new projects** and for **existing projects**.
|
|
64
64
|
|
|
65
|
+
#### CLI quick reference
|
|
66
|
+
|
|
67
|
+
| Adapter | Init command |
|
|
68
|
+
|---------|----------------------------------------------------|
|
|
69
|
+
| Express | `npx @codexsploitx/schemaapi init express` |
|
|
70
|
+
| Next.js | `npx @codexsploitx/schemaapi init next` |
|
|
71
|
+
| Fastify | `npx @codexsploitx/schemaapi init fastify` |
|
|
72
|
+
| Remix | `npx @codexsploitx/schemaapi init remix` |
|
|
73
|
+
| NestJS | `npx @codexsploitx/schemaapi init nest` |
|
|
74
|
+
| Deno | `npx @codexsploitx/schemaapi init deno` |
|
|
75
|
+
|
|
65
76
|
#### Express
|
|
66
77
|
|
|
67
78
|
- 🆕 **New project**
|
|
@@ -69,15 +80,15 @@ Below are the recommended commands for **new projects** and for **existing proje
|
|
|
69
80
|
```bash
|
|
70
81
|
mkdir my-express-api && cd my-express-api
|
|
71
82
|
npm init -y
|
|
72
|
-
npm install express schemaapi zod
|
|
73
|
-
npx schemaapi init express
|
|
83
|
+
npm install express @codexsploitx/schemaapi zod
|
|
84
|
+
npx @codexsploitx/schemaapi init express
|
|
74
85
|
```
|
|
75
86
|
|
|
76
87
|
- ♻️ **Existing Express project**
|
|
77
88
|
|
|
78
89
|
```bash
|
|
79
|
-
npm install schemaapi zod
|
|
80
|
-
npx schemaapi init express
|
|
90
|
+
npm install @codexsploitx/schemaapi zod
|
|
91
|
+
npx @codexsploitx/schemaapi init express
|
|
81
92
|
```
|
|
82
93
|
|
|
83
94
|
#### Next.js
|
|
@@ -87,15 +98,15 @@ npx schemaapi init express
|
|
|
87
98
|
```bash
|
|
88
99
|
npx create-next-app@latest my-next-api --ts
|
|
89
100
|
cd my-next-api
|
|
90
|
-
npm install schemaapi zod
|
|
91
|
-
npx schemaapi init next
|
|
101
|
+
npm install @codexsploitx/schemaapi zod
|
|
102
|
+
npx @codexsploitx/schemaapi init next
|
|
92
103
|
```
|
|
93
104
|
|
|
94
105
|
- ♻️ **Existing Next.js project**
|
|
95
106
|
|
|
96
107
|
```bash
|
|
97
|
-
npm install schemaapi zod
|
|
98
|
-
npx schemaapi init next
|
|
108
|
+
npm install @codexsploitx/schemaapi zod
|
|
109
|
+
npx @codexsploitx/schemaapi init next
|
|
99
110
|
```
|
|
100
111
|
|
|
101
112
|
El comando `schemaapi init next` creará automáticamente:
|
|
@@ -112,15 +123,15 @@ El comando `schemaapi init next` creará automáticamente:
|
|
|
112
123
|
```bash
|
|
113
124
|
mkdir my-fastify-api && cd my-fastify-api
|
|
114
125
|
npm init -y
|
|
115
|
-
npm install fastify schemaapi zod
|
|
116
|
-
npx schemaapi init fastify
|
|
126
|
+
npm install fastify @codexsploitx/schemaapi zod
|
|
127
|
+
npx @codexsploitx/schemaapi init fastify
|
|
117
128
|
```
|
|
118
129
|
|
|
119
130
|
- ♻️ **Existing Fastify project**
|
|
120
131
|
|
|
121
132
|
```bash
|
|
122
|
-
npm install schemaapi zod
|
|
123
|
-
npx schemaapi init fastify
|
|
133
|
+
npm install @codexsploitx/schemaapi zod
|
|
134
|
+
npx @codexsploitx/schemaapi init fastify
|
|
124
135
|
```
|
|
125
136
|
|
|
126
137
|
#### Remix
|
|
@@ -129,16 +140,15 @@ npx schemaapi init fastify
|
|
|
129
140
|
|
|
130
141
|
```bash
|
|
131
142
|
npx create-remix@latest
|
|
132
|
-
npm install schemaapi zod
|
|
133
|
-
npx schemaapi init remix
|
|
143
|
+
npm install @codexsploitx/schemaapi zod
|
|
144
|
+
npx @codexsploitx/schemaapi init remix
|
|
134
145
|
```
|
|
135
146
|
|
|
136
147
|
- ♻️ **Existing Remix project**
|
|
137
148
|
|
|
138
149
|
```bash
|
|
139
|
-
npm install schemaapi zod
|
|
140
|
-
npx schemaapi init remix
|
|
141
|
-
```
|
|
150
|
+
npm install @codexsploitx/schemaapi zod
|
|
151
|
+
npx @codexsploitx/schemaapi init remix
|
|
142
152
|
|
|
143
153
|
#### NestJS
|
|
144
154
|
|
|
@@ -148,15 +158,15 @@ npx schemaapi init remix
|
|
|
148
158
|
npm i -g @nestjs/cli
|
|
149
159
|
nest new my-nest-api
|
|
150
160
|
cd my-nest-api
|
|
151
|
-
npm install schemaapi zod
|
|
152
|
-
npx schemaapi init nest
|
|
161
|
+
npm install @codexsploitx/schemaapi zod
|
|
162
|
+
npx @codexsploitx/schemaapi init nest
|
|
153
163
|
```
|
|
154
164
|
|
|
155
165
|
- ♻️ **Existing NestJS project**
|
|
156
166
|
|
|
157
167
|
```bash
|
|
158
|
-
npm install schemaapi zod
|
|
159
|
-
npx schemaapi init nest
|
|
168
|
+
npm install @codexsploitx/schemaapi zod
|
|
169
|
+
npx @codexsploitx/schemaapi init nest
|
|
160
170
|
```
|
|
161
171
|
|
|
162
172
|
#### Deno
|
|
@@ -167,8 +177,8 @@ En Deno no se usa npm para el runtime, pero puedes usar SchemaApi en tu
|
|
|
167
177
|
tooling o en proyectos que usen `deno2node`. Para Node+Deno híbrido:
|
|
168
178
|
|
|
169
179
|
```bash
|
|
170
|
-
npm install schemaapi zod
|
|
171
|
-
npx schemaapi init deno
|
|
180
|
+
npm install @codexsploitx/schemaapi zod
|
|
181
|
+
npx @codexsploitx/schemaapi init deno
|
|
172
182
|
```
|
|
173
183
|
|
|
174
184
|
---
|
|
@@ -180,7 +190,7 @@ npx schemaapi init deno
|
|
|
180
190
|
Create a shared file (e.g., `contract.ts`). This is your API's law.
|
|
181
191
|
|
|
182
192
|
```typescript
|
|
183
|
-
import { createContract } from "schemaapi";
|
|
193
|
+
import { createContract } from "@codexsploitx/schemaapi";
|
|
184
194
|
import { z } from "zod";
|
|
185
195
|
|
|
186
196
|
export const contract = createContract({
|
|
@@ -231,7 +241,7 @@ app.get(
|
|
|
231
241
|
No more manual fetch calls. No more `any`.
|
|
232
242
|
|
|
233
243
|
```typescript
|
|
234
|
-
import { createClient } from "schemaapi";
|
|
244
|
+
import { createClient } from "@codexsploitx/schemaapi";
|
|
235
245
|
import { contract } from "./shared/contract";
|
|
236
246
|
|
|
237
247
|
const client = createClient(contract, {
|