Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion __tests__/typescript-stress.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,33 @@ const services = {
requestInit: Type.Object({}),
requestData: Type.Object({ n: Type.Number() }),
responseData: Type.Object({ n: Type.Number() }),
async handler() {
responseError: flattenErrorType(
Type.Union([
Type.Object({
code: Type.Literal('ERROR1'),
message: Type.String(),
}),
Type.Object({
code: Type.Literal('ERROR2'),
message: Type.String(),
}),
]),
),
async handler({ ctx, reqReadable }) {
for await (const { ok, payload } of reqReadable) {
if (!ok) {
return ctx.cancel();
}

if (payload.n === 1) {
return Err({ code: 'ERROR1', message: 'n is 1' });
}

if (payload.n === 2) {
return Err({ code: 'ERROR2', message: 'n is 2' });
}
}

return Ok({ n: 1 });
},
}),
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@replit/river",
"description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!",
"version": "0.206.0",
"version": "0.207.0",
"type": "module",
"exports": {
".": {
Expand Down
2 changes: 1 addition & 1 deletion router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export type {
ServiceContext,
ProcedureHandlerContext,
} from './context';
export { Ok, Err, unwrapOrThrow } from './result';
export { Ok, Err } from './result';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By misusing you mean they never attempt to handle expected errors/laziness? That's probably right, and I might be an offender.

export type {
Result,
ErrResult,
Expand Down