Skip to content

Commit 25cfa7c

Browse files
committed
refactor(nest): merge middleapi/orpc-nest back into middleapi/orpc
1 parent c398af6 commit 25cfa7c

46 files changed

Lines changed: 5332 additions & 60 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/content/docs/playgrounds.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ featuring pre-configured examples accessible instantly via StackBlitz or local s
55

66
## Available Playgrounds
77

8-
| Environment | StackBlitz | GitHub Source |
9-
| ------------------ | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
10-
| Next.js Playground | [Open in StackBlitz](https://stackblitz.com/github/middleapi/orpc/tree/main/playgrounds/next) | [View Source](https://github.com/middleapi/orpc/tree/main/playgrounds/next) |
11-
| NestJS Playground | [Open in StackBlitz](https://stackblitz.com/github/middleapi/orpc-nest/tree/main/playgrounds/nest) | [View Source](https://github.com/middleapi/orpc-nest/tree/main/playgrounds/nest) |
8+
| Environment | StackBlitz | GitHub Source |
9+
| ------------------ | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
10+
| Next.js Playground | [Open in StackBlitz](https://stackblitz.com/github/middleapi/orpc/tree/main/playgrounds/next) | [View Source](https://github.com/middleapi/orpc/tree/main/playgrounds/next) |
11+
| NestJS Playground | [Open in StackBlitz](https://stackblitz.com/github/middleapi/orpc/tree/main/playgrounds/nest) | [View Source](https://github.com/middleapi/orpc/tree/main/playgrounds/nest) |
1212

1313
:::warning
1414
StackBlitz has its own limitations, so some features may not work as expected.
@@ -20,7 +20,7 @@ Prefer working locally? Clone the playground with:
2020

2121
```bash
2222
npx giget gh:middleapi/orpc/playgrounds/next orpc-next-playground
23-
npx giget gh:middleapi/orpc-nest/playgrounds/nest orpc-nest-playground
23+
npx giget gh:middleapi/orpc/playgrounds/nest orpc-nest-playground
2424
```
2525

2626
Then install dependencies and start the dev server:

apps/content/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@orpc/valibot": "workspace:*",
2626
"@orpc/zod": "workspace:*",
2727
"@shikijs/vitepress-twoslash": "^4.2.0",
28-
"@tanstack/react-query": "^5.101.0",
28+
"@tanstack/react-query": "^5.101.1",
2929
"@tanstack/solid-query": "^5.101.0",
3030
"@tanstack/svelte-query": "^6.1.34",
3131
"@tanstack/vue-query": "^5.101.0",

integrations/nest.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/nest/.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Hidden folders and files
2+
.*
3+
!.gitignore
4+
!.*.example
5+
6+
# Common generated folders
7+
logs/
8+
node_modules/
9+
out/
10+
dist/
11+
dist-ssr/
12+
build/
13+
coverage/
14+
temp/
15+
16+
# Common generated files
17+
*.log
18+
*.log.*
19+
*.tsbuildinfo
20+
*.vitest-temp.json
21+
vite.config.ts.timestamp-*
22+
vitest.config.ts.timestamp-*
23+
24+
# Common manual ignore files
25+
*.local
26+
*.pem

packages/nest/README.md

Lines changed: 191 additions & 0 deletions
Large diffs are not rendered by default.

packages/nest/build.config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineBuildConfig } from 'unbuild'
2+
3+
export default defineBuildConfig({
4+
rollup: {
5+
esbuild: {
6+
tsconfigRaw: {
7+
compilerOptions: {
8+
experimentalDecorators: true,
9+
},
10+
},
11+
},
12+
},
13+
})

packages/nest/package.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"name": "@orpc/nest",
3+
"type": "module",
4+
"version": "2.0.0-beta.4",
5+
"license": "MIT",
6+
"homepage": "https://orpc.dev",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/middleapi/orpc.git",
10+
"directory": "packages/nest"
11+
},
12+
"sideEffects": false,
13+
"publishConfig": {
14+
"exports": {
15+
"./package.json": "./package.json",
16+
".": {
17+
"types": "./dist/index.d.mts",
18+
"import": "./dist/index.mjs",
19+
"default": "./dist/index.mjs"
20+
}
21+
}
22+
},
23+
"exports": {
24+
"./package.json": "./package.json",
25+
".": "./src/index.ts"
26+
},
27+
"files": [
28+
"dist"
29+
],
30+
"scripts": {
31+
"build": "unbuild",
32+
"type:check": "tsc -b"
33+
},
34+
"peerDependencies": {
35+
"@nestjs/common": ">=11.1.27",
36+
"@nestjs/core": ">=11.1.27",
37+
"express": ">=5.2.1",
38+
"fastify": ">=5.8.5",
39+
"rxjs": ">=7.8.2"
40+
},
41+
"peerDependenciesMeta": {
42+
"express": {
43+
"optional": true
44+
},
45+
"fastify": {
46+
"optional": true
47+
}
48+
},
49+
"dependencies": {
50+
"@orpc/client": "workspace:*",
51+
"@orpc/contract": "workspace:*",
52+
"@orpc/openapi": "workspace:*",
53+
"@orpc/server": "workspace:*",
54+
"@orpc/shared": "workspace:*",
55+
"@standardserver/core": "^0.0.25",
56+
"@standardserver/node": "^0.0.25"
57+
},
58+
"devDependencies": {
59+
"@fastify/cookie": "^11.0.2",
60+
"@nestjs/common": "^11.1.27",
61+
"@nestjs/core": "^11.1.27",
62+
"@nestjs/platform-express": "^11.1.27",
63+
"@nestjs/platform-fastify": "^11.1.27",
64+
"@nestjs/testing": "^11.1.27",
65+
"express": "^5.2.1",
66+
"fastify": "^5.8.5",
67+
"rxjs": "^7.8.2"
68+
}
69+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import { oc } from '@orpc/contract'
2+
import { implement, os } from '@orpc/server'
3+
import { describe, it } from 'vitest'
4+
import { z } from 'zod'
5+
import { Implement } from './implement'
6+
7+
export const inputSchema = z.object({ input: z.number().transform(n => `${n}`) })
8+
9+
export const outputSchema = z.object({ output: z.number().transform(n => `${n}`) })
10+
11+
describe('@Implement', () => {
12+
it('require return an implemented procedure that satisfy default initial context', () => {
13+
const contract = oc.input(inputSchema).output(outputSchema)
14+
15+
class _ImplProcedureController {
16+
@Implement(contract)
17+
ping() {
18+
return implement(contract).handler(() => ({}) as any)
19+
}
20+
21+
@Implement(contract)
22+
ping_with_middleware_context() {
23+
return implement(contract).use(({ next }) => next({ context: { extra: 'value' } })).handler(() => ({}) as any)
24+
}
25+
26+
// @ts-expect-error --- return invalid
27+
@Implement(contract)
28+
ping_invalid() {
29+
return 'invalid'
30+
}
31+
32+
// @ts-expect-error --- initial context is not allowed
33+
@Implement(contract)
34+
ping_invalid_initial_context() {
35+
return implement(contract).$context<{ a: string }>().handler(() => ({}) as any)
36+
}
37+
38+
// @ts-expect-error --- implement wrong contract
39+
@Implement(contract)
40+
ping_wrong_implement() {
41+
return implement(oc.input(inputSchema)).handler(() => ({}) as any)
42+
}
43+
}
44+
})
45+
46+
it('require return an implemented router that satisfy default initial context', () => {
47+
const contract = {
48+
ping: oc.input(inputSchema).output(outputSchema),
49+
}
50+
51+
class _ImplProcedureController {
52+
@Implement(contract)
53+
ping() {
54+
return {
55+
ping: implement(contract.ping).handler(() => ({}) as any),
56+
}
57+
}
58+
59+
@Implement(contract)
60+
ping_with_middleware_context() {
61+
return {
62+
ping: implement(contract.ping).use(({ next }) => next({ context: { extra: 'value' } })).handler(() => ({}) as any),
63+
}
64+
}
65+
66+
@Implement(contract)
67+
ping_with_lazy() {
68+
return {
69+
ping: os.lazy(() => Promise.resolve({ default: implement(contract.ping).handler(() => ({}) as any) })),
70+
}
71+
}
72+
73+
// @ts-expect-error --- return invalid
74+
@Implement(contract)
75+
ping_invalid() {
76+
return 'invalid'
77+
}
78+
79+
// @ts-expect-error --- initial context is not allowed
80+
@Implement(contract)
81+
ping_invalid_initial_context() {
82+
return {
83+
ping: implement(contract.ping).$context<{ a: string }>().handler(() => ({}) as any),
84+
}
85+
}
86+
87+
// @ts-expect-error --- initial context is not allowed
88+
@Implement(contract)
89+
ping_invalid_initial_context_lazy() {
90+
return {
91+
ping: os.lazy(() => Promise.resolve({ default: implement(contract.ping).$context<{ a: string }>().handler(() => ({}) as any) })),
92+
}
93+
}
94+
95+
// @ts-expect-error --- implement wrong contract
96+
@Implement(contract)
97+
ping_wrong_implement() {
98+
return {
99+
ping: implement(oc.input(inputSchema)).handler(() => ({}) as any),
100+
}
101+
}
102+
103+
// @ts-expect-error --- implement wrong contract
104+
@Implement(contract)
105+
ping_wrong_implement_lazy() {
106+
return {
107+
ping: os.lazy(() => Promise.resolve({ default: implement(oc.input(inputSchema)).handler(() => ({}) as any) })),
108+
}
109+
}
110+
}
111+
})
112+
})

0 commit comments

Comments
 (0)