@orpc/nest 0.0.0-next.d888fab → 0.0.1
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 +1 -55
- package/dist/index.mjs +2 -7
- package/package.json +10 -10
package/README.md
CHANGED
@@ -63,61 +63,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
63
63
|
|
64
64
|
## `@orpc/nest`
|
65
65
|
|
66
|
-
Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
67
|
-
|
68
|
-
### Implement Contract
|
69
|
-
|
70
|
-
An overview of how to implement an [oRPC contract](https://orpc.unnoq.com/docs/contract-first/define-contract) in NestJS.
|
71
|
-
|
72
|
-
```ts
|
73
|
-
import { Implement, implement, ORPCError } from '@orpc/nest'
|
74
|
-
|
75
|
-
@Controller()
|
76
|
-
export class PlanetController {
|
77
|
-
/**
|
78
|
-
* Implement a standalone procedure
|
79
|
-
*/
|
80
|
-
@Implement(contract.planet.list)
|
81
|
-
list() {
|
82
|
-
return implement(contract.planet.list).handler(({ input }) => {
|
83
|
-
// Implement logic here
|
84
|
-
|
85
|
-
return []
|
86
|
-
})
|
87
|
-
}
|
88
|
-
|
89
|
-
/**
|
90
|
-
* Implement entire a contract
|
91
|
-
*/
|
92
|
-
@Implement(contract.planet)
|
93
|
-
planet() {
|
94
|
-
return {
|
95
|
-
list: implement(contract.planet.list).handler(({ input }) => {
|
96
|
-
// Implement logic here
|
97
|
-
return []
|
98
|
-
}),
|
99
|
-
find: implement(contract.planet.find).handler(({ input }) => {
|
100
|
-
// Implement logic here
|
101
|
-
return {
|
102
|
-
id: 1,
|
103
|
-
name: 'Earth',
|
104
|
-
description: 'The planet Earth',
|
105
|
-
}
|
106
|
-
}),
|
107
|
-
create: implement(contract.planet.create).handler(({ input }) => {
|
108
|
-
// Implement logic here
|
109
|
-
return {
|
110
|
-
id: 1,
|
111
|
-
name: 'Earth',
|
112
|
-
description: 'The planet Earth',
|
113
|
-
}
|
114
|
-
}),
|
115
|
-
}
|
116
|
-
}
|
117
|
-
|
118
|
-
// other handlers...
|
119
|
-
}
|
120
|
-
```
|
66
|
+
Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
121
67
|
|
122
68
|
## Sponsors
|
123
69
|
|
package/dist/index.mjs
CHANGED
@@ -3,10 +3,9 @@ import { toORPCError } from '@orpc/client';
|
|
3
3
|
import { isContractProcedure, ContractProcedure, fallbackContractConfig } from '@orpc/contract';
|
4
4
|
import { standardizeHTTPPath, StandardOpenAPISerializer, StandardOpenAPIJsonSerializer, StandardBracketNotationSerializer } from '@orpc/openapi-client/standard';
|
5
5
|
import { StandardOpenAPICodec } from '@orpc/openapi/standard';
|
6
|
-
import { getRouter, unlazy, isProcedure,
|
6
|
+
import { getRouter, unlazy, isProcedure, call, ORPCError } from '@orpc/server';
|
7
7
|
export { ORPCError, implement } from '@orpc/server';
|
8
8
|
import { toArray, get } from '@orpc/shared';
|
9
|
-
import { flattenHeader } from '@orpc/standard-server';
|
10
9
|
import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-node';
|
11
10
|
import { mergeMap } from 'rxjs';
|
12
11
|
import { toHttpPath } from '@orpc/client/standard';
|
@@ -108,14 +107,10 @@ class ImplementInterceptor {
|
|
108
107
|
const standardResponse = await (async () => {
|
109
108
|
let isDecoding = false;
|
110
109
|
try {
|
111
|
-
const client = createProcedureClient(procedure);
|
112
110
|
isDecoding = true;
|
113
111
|
const input = await codec.decode(standardRequest, flattenParams(req.params), procedure);
|
114
112
|
isDecoding = false;
|
115
|
-
const output = await
|
116
|
-
signal: standardRequest.signal,
|
117
|
-
lastEventId: flattenHeader(standardRequest.headers["last-event-id"])
|
118
|
-
});
|
113
|
+
const output = await call(procedure, input);
|
119
114
|
return codec.encode(output, procedure);
|
120
115
|
} catch (e) {
|
121
116
|
const error = isDecoding && !(e instanceof ORPCError) ? new ORPCError("BAD_REQUEST", {
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/nest",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.
|
4
|
+
"version": "0.0.1",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -28,7 +28,8 @@
|
|
28
28
|
"@nestjs/core": ">=11.0.0",
|
29
29
|
"express": ">=5.0.0",
|
30
30
|
"fastify": ">=5.0.0",
|
31
|
-
"rxjs": ">=7.0.0"
|
31
|
+
"rxjs": ">=7.0.0",
|
32
|
+
"@orpc/contract": "1.2.0"
|
32
33
|
},
|
33
34
|
"peerDependenciesMeta": {
|
34
35
|
"express": {
|
@@ -39,14 +40,13 @@
|
|
39
40
|
}
|
40
41
|
},
|
41
42
|
"dependencies": {
|
42
|
-
"@orpc/client": "
|
43
|
-
"@orpc/
|
44
|
-
"@orpc/
|
45
|
-
"@orpc/openapi-client": "
|
46
|
-
"@orpc/
|
47
|
-
"@orpc/
|
48
|
-
"@orpc/standard-server": "
|
49
|
-
"@orpc/standard-server-node": "0.0.0-next.d888fab"
|
43
|
+
"@orpc/client": "1.2.0",
|
44
|
+
"@orpc/openapi": "1.2.0",
|
45
|
+
"@orpc/server": "1.2.0",
|
46
|
+
"@orpc/openapi-client": "1.2.0",
|
47
|
+
"@orpc/shared": "1.2.0",
|
48
|
+
"@orpc/standard-server": "1.2.0",
|
49
|
+
"@orpc/standard-server-node": "1.2.0"
|
50
50
|
},
|
51
51
|
"devDependencies": {
|
52
52
|
"@nestjs/common": "^11.1.0",
|