@seam-rpc/server 5.1.2 → 5.1.4
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/dist/index.js +5 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42,7 +42,10 @@ function createProcedureBuilder(definition = {}) {
|
|
|
42
42
|
function defineSeamRouter(seamSpace, path, seamRouterBuilder) {
|
|
43
43
|
const router = Router();
|
|
44
44
|
router.post("/:procName", async (req, res, next) => {
|
|
45
|
-
const
|
|
45
|
+
const procedureBuilder = seamRouterBuilder[req.params.procName];
|
|
46
|
+
if (!procedureBuilder)
|
|
47
|
+
return res.sendStatus(404);
|
|
48
|
+
const procedure = procedureBuilder._def;
|
|
46
49
|
if (!procedure || !procedure.handler)
|
|
47
50
|
return res.sendStatus(404);
|
|
48
51
|
let input;
|
|
@@ -121,7 +124,7 @@ function defineSeamRouter(seamSpace, path, seamRouterBuilder) {
|
|
|
121
124
|
}
|
|
122
125
|
// Validate output
|
|
123
126
|
try {
|
|
124
|
-
validatedOutput = validateOutput(output, z.object({ ok: z.literal(true), data: procedure.output }).or(z.object({ ok: z.literal(false), error: z.any() })));
|
|
127
|
+
validatedOutput = validateOutput(output, z.object({ ok: z.literal(true), data: procedure.output ?? z.undefined() }).or(z.object({ ok: z.literal(false), error: z.any() })));
|
|
125
128
|
}
|
|
126
129
|
catch (err) {
|
|
127
130
|
seamSpace.emit("outputValidationError", err, {
|