trpc-to-openapi
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -20,2 +20,3 @@ "use strict"; | ||
return await openApiHttpHandler(rawRequest, Object.assign(reply, { | ||
once: () => undefined, | ||
setHeader: (key, value) => { | ||
@@ -22,0 +23,0 @@ if (Array.isArray(value)) { |
@@ -41,3 +41,3 @@ "use strict"; | ||
} | ||
(0, node_http_1.incomingMessageToRequest)(Object.assign(req, { | ||
(0, node_http_1.incomingMessageToRequest)(req, Object.assign(res, { | ||
once: () => undefined, | ||
@@ -44,0 +44,0 @@ }), { |
@@ -67,3 +67,3 @@ "use strict"; | ||
? req | ||
: (0, node_http_1.incomingMessageToRequest)(req, { | ||
: (0, node_http_1.incomingMessageToRequest)(req, res, { | ||
maxBodySize: maxBodySize !== null && maxBodySize !== void 0 ? maxBodySize : null, | ||
@@ -87,3 +87,3 @@ }), | ||
for (const [key, shape] of Object.entries(unwrappedSchema.shape)) { | ||
if (shape instanceof zod_1.ZodArray && typeof input[key] === 'string') { | ||
if (shape instanceof zod_1.ZodArray && !Array.isArray(input[key])) { | ||
input[key] = [input[key]]; | ||
@@ -90,0 +90,0 @@ } |
@@ -10,3 +10,3 @@ "use strict"; | ||
var _a; | ||
await openApiHttpHandler((0, node_http_1.incomingMessageToRequest)(req, { | ||
await openApiHttpHandler((0, node_http_1.incomingMessageToRequest)(req, res, { | ||
maxBodySize: (_a = opts.maxBodySize) !== null && _a !== void 0 ? _a : null, | ||
@@ -13,0 +13,0 @@ }), res); |
{ | ||
"name": "trpc-to-openapi", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "tRPC OpenAPI", | ||
@@ -52,3 +52,3 @@ "author": "mcampa", | ||
"peerDependencies": { | ||
"@trpc/server": "^11.0.0-rc.566", | ||
"@trpc/server": "^11.0.0-rc.648", | ||
"zod": "^3.23.8" | ||
@@ -60,3 +60,2 @@ }, | ||
"lodash.clonedeep": "^4.5.0", | ||
"node-mocks-http": "^1.12.2", | ||
"openapi3-ts": "4.3.3", | ||
@@ -66,3 +65,3 @@ "zod-openapi": "^2.19.0" | ||
"devDependencies": { | ||
"@trpc/client": "^11.0.0-rc.566", | ||
"@trpc/client": "^11.0.0-rc.648", | ||
"@types/aws-lambda": "^8.10.115", | ||
@@ -82,2 +81,3 @@ "@types/co-body": "^6.1.0", | ||
"next": "^14.2.10", | ||
"node-mocks-http": "^1.12.2", | ||
"node-fetch": "^2.6.11", | ||
@@ -90,3 +90,3 @@ "openapi-schema-validator": "^12.1.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "5.5.4" | ||
"typescript": "5.7.2" | ||
}, | ||
@@ -93,0 +93,0 @@ "optionalDependencies": { |
@@ -14,3 +14,3 @@ <p align="center"> | ||
- tRPC 11 only π | ||
- tRPC ^11.0.0-rc.648 only π | ||
- Easy REST endpoints for your tRPC procedures. | ||
@@ -24,2 +24,3 @@ - Perfect for incremental adoption. | ||
- 2.0.4 Upgrade to tRPC 11.0.0-rc.648 | ||
- 2.0.3 Added support for array inputs for GET requests | ||
@@ -82,3 +83,3 @@ | ||
No support for AWS lambdas yet π’ | ||
No support for AWS lambdas | ||
@@ -128,3 +129,3 @@ ```typescript | ||
Procedures with a `GET`/`DELETE` method will accept inputs via URL `query parameters`. Procedures with a `POST`/`PATCH`/`PUT` method will accept inputs via the `request body` with a `application/json` or `application/x-www-form-urlencoded` content type. | ||
Procedures with a `GET`/`DELETE` method will accept inputs via URL `query parameters`. Procedures with a `POST`/`PATCH`/`PUT` method will accept inputs via the `request body` with a `application/json` content type. | ||
@@ -274,4 +275,38 @@ ### Path parameters | ||
#### With Next.js | ||
#### With Next.js app router | ||
Please see [full example here](examples/with-nextjs-appdir). | ||
```typescript | ||
// src/app/[...trpc]/route.ts | ||
import { appRouter } from '~/server/api/root'; | ||
import { createContext } from '~/server/api/trpc'; | ||
import { type NextRequest } from 'next/server'; | ||
import { createOpenApiFetchHandler } from 'trpc-to-openapi'; | ||
export const dynamic = 'force-dynamic'; | ||
const handler = (req: NextRequest) => { | ||
// Handle incoming OpenAPI requests | ||
return createOpenApiFetchHandler({ | ||
endpoint: '/', | ||
router: appRouter, | ||
createContext: () => createContext(req), | ||
req, | ||
}); | ||
}; | ||
export { | ||
handler as GET, | ||
handler as POST, | ||
handler as PUT, | ||
handler as PATCH, | ||
handler as DELETE, | ||
handler as OPTIONS, | ||
handler as HEAD, | ||
}; | ||
``` | ||
#### With Next.js pages router | ||
Please see [full example here](examples/with-nextjs). | ||
@@ -278,0 +313,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
255820
8
2667
396
24
- Removednode-mocks-http@^1.12.2
- Removedaccepts@1.3.8(transitive)
- Removedcontent-disposition@0.5.4(transitive)
- Removeddepd@1.1.2(transitive)
- Removedfresh@0.5.2(transitive)
- Removedmerge-descriptors@1.0.3(transitive)
- Removedmethods@1.1.2(transitive)
- Removedmime@1.6.0(transitive)
- Removednegotiator@0.6.3(transitive)
- Removednode-mocks-http@1.16.2(transitive)
- Removedparseurl@1.3.3(transitive)
- Removedrange-parser@1.2.1(transitive)
- Removedsafe-buffer@5.2.1(transitive)