Skip to content

Commit

Permalink
Made AppendResult to return next expected version without null
Browse files Browse the repository at this point in the history
Assumed that if that fails then either it shall throw exception, or we should introduce more explicit result for supported failures
  • Loading branch information
oskardudycz committed Feb 19, 2024
1 parent e47faae commit 274ad01
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ One of the mentioned benefits is testing, which Emmett helps to do out of the bo

Tests for our Shopping Cart business logic can look like this:

<<< @/snippets/gettingStarted/businessLogic.unit.test.ts#getting-started-unit-tests
<<< @/snippets/gettingStarted/businessLogic.unit.spec.ts#getting-started-unit-tests
10 changes: 5 additions & 5 deletions packages/emmett-expressjs/src/e2e/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const shoppingCartApi = (eventStore: EventStore) => (router: Router) => {
{ expectedStreamVersion: STREAM_DOES_NOT_EXIST },
);

setETag(response, toWeakETag(result!.nextExpectedStreamVersion));
setETag(response, toWeakETag(result.nextExpectedStreamVersion));
sendCreated(response, shoppingCartId);
},
);
Expand Down Expand Up @@ -82,7 +82,7 @@ export const shoppingCartApi = (eventStore: EventStore) => (router: Router) => {
{ expectedStreamVersion: getExpectedStreamVersion(request) },
);

setETag(response, toWeakETag(result!.nextExpectedStreamVersion));
setETag(response, toWeakETag(result.nextExpectedStreamVersion));
response.sendStatus(204);
},
);
Expand Down Expand Up @@ -110,7 +110,7 @@ export const shoppingCartApi = (eventStore: EventStore) => (router: Router) => {
{ expectedStreamVersion: getExpectedStreamVersion(request) },
);

setETag(response, toWeakETag(result!.nextExpectedStreamVersion));
setETag(response, toWeakETag(result.nextExpectedStreamVersion));
response.sendStatus(204);
},
);
Expand All @@ -133,7 +133,7 @@ export const shoppingCartApi = (eventStore: EventStore) => (router: Router) => {
{ expectedStreamVersion: getExpectedStreamVersion(request) },
);

setETag(response, toWeakETag(result!.nextExpectedStreamVersion));
setETag(response, toWeakETag(result.nextExpectedStreamVersion));
response.sendStatus(204);
},
);
Expand All @@ -156,7 +156,7 @@ export const shoppingCartApi = (eventStore: EventStore) => (router: Router) => {
{ expectedStreamVersion: getExpectedStreamVersion(request) },
);

setETag(response, toWeakETag(result!.nextExpectedStreamVersion));
setETag(response, toWeakETag(result.nextExpectedStreamVersion));
response.sendStatus(204);
},
);
Expand Down
2 changes: 1 addition & 1 deletion packages/emmett/src/eventStore/eventStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ export type AppendToStreamOptions<StreamVersion = DefaultStreamVersionType> = {

export type AppendToStreamResult<StreamVersion = DefaultStreamVersionType> = {
nextExpectedStreamVersion: StreamVersion;
} | null;
};
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"exclude": ["node_modules", "tmp"],
"files": [],
"compilerOptions": {
"disableSourceOfProjectReferenceRedirect": true,
"noEmit": true /* Do not emit outputs. */,
"paths": {
"@event-driven-io/emmett": ["./packages/emmett/src"],
Expand Down

0 comments on commit 274ad01

Please sign in to comment.