Skip to content

Commit 5e8c2e6

Browse files
authored
chore: Migrate from npm to pnpm (#132)
* chore: Migratefrom npm to pnpm * Update Node.js version matrix in CI workflow to remove 18.x * Fix example apps * Fix fastify example
1 parent 9871f74 commit 5e8c2e6

File tree

33 files changed

+13109
-18634
lines changed

33 files changed

+13109
-18634
lines changed

.github/workflows/node.js.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
node-version: [18.x, 20.x, 22.x, 24.x]
18+
node-version: [20.x, 22.x, 24.x]
1919
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
2020

2121
steps:
2222
- uses: actions/checkout@v4
23+
- name: Install pnpm
24+
uses: pnpm/action-setup@v4
2325
- name: Use Node.js ${{ matrix.node-version }}
2426
uses: actions/setup-node@v4
2527
with:
2628
node-version: ${{ matrix.node-version }}
27-
cache: "npm"
28-
- run: npm ci
29-
- run: npm run build
30-
- run: npm test
29+
cache: "pnpm"
30+
- run: pnpm install --frozen-lockfile
31+
- run: pnpm run build
32+
- run: pnpm test

.github/workflows/npm-publish.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v4
1717

18+
- name: Install pnpm
19+
uses: pnpm/action-setup@v4
20+
1821
- name: Use Node.js
1922
uses: actions/setup-node@v4
2023
with:
2124
node-version: 22.x
22-
registry-url: 'https://registry.npmjs.org'
23-
cache: 'npm'
25+
registry-url: "https://registry.npmjs.org"
26+
cache: "pnpm"
2427

2528
- name: Install dependencies
26-
run: npm ci
29+
run: pnpm install --frozen-lockfile
2730

2831
- name: Check if version is publishable
2932
id: check_version
@@ -45,11 +48,11 @@ jobs:
4548
4649
- name: Build package
4750
if: steps.check_version.outputs.should_publish == 'true'
48-
run: npm run build
51+
run: pnpm run build
4952

5053
- name: Publish to NPM
5154
if: steps.check_version.outputs.should_publish == 'true'
52-
run: npm publish
55+
run: pnpm publish --no-git-checks
5356
env:
5457
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5558

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
dist
3-
.DS_Store
3+
.DS_Store
4+
.claude

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Note: This project is a fork of a fork, with full credit to the original authors
2323
**1. Install `trpc-to-openapi`.**
2424

2525
```bash
26+
# pnpm
27+
pnpm add trpc-to-openapi
2628
# npm
2729
npm install trpc-to-openapi
2830
# yarn
@@ -400,8 +402,6 @@ Please see [full typings here](src/adapters/node-http/core.ts).
400402

401403
---
402404

403-
_Still using tRPC v9? See our [`.interop()`](examples/with-interop) example._
404-
405405
## License
406406

407407
Distributed under the MIT License. See LICENSE for more information.

examples/with-express/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
### Getting started
44

5-
Make sure your current working directory is at `/trpc-to-openapi` root.
6-
75
```bash
8-
npm install
9-
npm run build
10-
npm run dev -w with-express
6+
pnpm install
7+
pnpm run build
8+
pnpm run dev -w with-express
119
```

examples/with-express/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.0",
44
"private": true,
55
"scripts": {
6-
"dev": "ts-node-dev --respawn --transpile-only --exit-child ./src/index.ts"
6+
"dev": "tsx ./src/index.ts"
77
},
88
"dependencies": {
99
"@trpc/server": "^11.1.0",
@@ -12,7 +12,9 @@
1212
"jsonwebtoken": "^9.0.0",
1313
"swagger-ui-express": "^4.6.3",
1414
"uuid": "^11.0.3",
15-
"zod": "^4.0.0"
15+
"trpc-to-openapi": "workspace:*",
16+
"zod": "^4.0.0",
17+
"zod-openapi": "5.4.2"
1618
},
1719
"devDependencies": {
1820
"@types/cors": "^2.8.13",
@@ -21,8 +23,7 @@
2123
"@types/node": "^22",
2224
"@types/swagger-ui-express": "^4.1.8",
2325
"@types/uuid": "^9.0.1",
24-
"ts-node": "^10.9.1",
25-
"ts-node-dev": "^2.0.0",
26-
"typescript": "^5.8.3"
26+
"tsx": "^4.20.0",
27+
"typescript": "5.8.3"
2728
}
2829
}

examples/with-express/src/openapi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const PostSchema = z.object({
2323
const ErrorSchema = z.object({
2424
message: z.string(),
2525
code: z.string(),
26-
details: z.record(z.any()).optional(),
26+
details: z.record(z.string(), z.string()).optional(),
2727
});
2828

2929
// Generate OpenAPI schema document

examples/with-fastify/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Make sure your current working directory is at `/trpc-to-openapi` root.
66

77
```bash
8-
npm install
9-
npm run build
10-
npm run dev -w with-fastify
8+
pnpm install
9+
pnpm run build
10+
pnpm run dev -w with-fastify
1111
```

examples/with-fastify/package.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@
33
"version": "1.0.0",
44
"private": true,
55
"scripts": {
6-
"dev": "ts-node-dev --respawn --transpile-only --exit-child ./src/index.ts"
6+
"dev": "tsx ./src/index.ts"
77
},
88
"dependencies": {
9-
"@fastify/cors": "^8.2.1",
10-
"@fastify/swagger": "^8.5.1",
11-
"@trpc/server": "^11.1.0",
12-
"fastify": "^4.17.0",
9+
"@fastify/cors": "9.0.1",
10+
"@fastify/static": "7.0.1",
11+
"@fastify/swagger": "8.15.0",
12+
"@fastify/swagger-ui": "2.1.0",
13+
"@trpc/server": "11.1.0",
14+
"fastify": "4.29.1",
1315
"jsonwebtoken": "^9.0.0",
1416
"uuid": "^11.0.3",
15-
"zod": "^4.0.0"
17+
"trpc-to-openapi": "workspace:*",
18+
"zod": "^4.0.0",
19+
"zod-openapi": "5.4.2"
1620
},
1721
"devDependencies": {
18-
"@types/cors": "^2.8.13",
19-
"@types/express": "^4.17.17",
2022
"@types/jsonwebtoken": "^9.0.2",
2123
"@types/node": "^22.15.14",
2224
"@types/uuid": "^9.0.1",
23-
"ts-node": "^10.9.1",
24-
"ts-node-dev": "^2.0.0",
25-
"typescript": "^5.8.3"
25+
"tsx": "^4.20.0",
26+
"typescript": "5.8.3"
2627
}
2728
}

examples/with-fastify/src/index.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
1-
/*
2-
eslint-disable
3-
@typescript-eslint/no-misused-promises,
4-
@typescript-eslint/no-unsafe-argument,
5-
@typescript-eslint/no-explicit-any,
6-
promise/always-return
7-
*/
81
import cors from '@fastify/cors';
92
import fastifySwagger from '@fastify/swagger';
103
import { fastifyTRPCPlugin } from '@trpc/server/adapters/fastify';
114
import Fastify from 'fastify';
125
import { fastifyTRPCOpenApiPlugin } from 'trpc-to-openapi';
13-
6+
import fastifySwaggerUi from '@fastify/swagger-ui';
147
import { openApiDocument } from './openapi';
158
import { appRouter, createContext } from './router';
169

17-
const app = Fastify();
10+
const app = Fastify({
11+
logger: true,
12+
});
1813

1914
async function main() {
2015
// Setup CORS
21-
await app.register(cors);
16+
17+
await app.register(cors, {});
2218

2319
// Handle incoming tRPC requests
20+
2421
await app.register(fastifyTRPCPlugin, {
2522
prefix: '/trpc',
2623
useWss: false,
2724
trpcOptions: { router: appRouter, createContext },
28-
} as any);
25+
});
2926

3027
// Handle incoming OpenAPI requests
28+
3129
await app.register(fastifyTRPCOpenApiPlugin, {
3230
basePath: '/api',
3331
router: appRouter,
@@ -38,18 +36,19 @@ async function main() {
3836
app.get('/openapi.json', () => openApiDocument);
3937

4038
// Server Swagger UI
39+
4140
await app.register(fastifySwagger, {
42-
routePrefix: '/docs',
4341
mode: 'static',
4442
specification: { document: openApiDocument },
45-
uiConfig: { displayOperationId: true },
46-
exposeRoute: true,
43+
});
44+
45+
await app.register(fastifySwaggerUi as any, {
46+
routePrefix: '/docs',
4747
});
4848

4949
await app
5050
.listen({ port: 3000 })
5151
.then((address) => {
52-
app.swagger();
5352
console.log(`Server started on ${address}\nSwagger UI: http://localhost:3000/docs`);
5453
})
5554
.catch((e) => {

0 commit comments

Comments
 (0)