From 274ad01e1dcb98341162f0d7d29438de85d18418 Mon Sep 17 00:00:00 2001 From: Oskar Dudycz Date: Mon, 19 Feb 2024 13:01:03 +0100 Subject: [PATCH] Made AppendResult to return next expected version without null Assumed that if that fails then either it shall throw exception, or we should introduce more explicit result for supported failures --- docs/getting-started.md | 2 +- packages/emmett-expressjs/src/e2e/api.ts | 10 +++++----- packages/emmett/src/eventStore/eventStore.ts | 2 +- tsconfig.json | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 96671557..346202f3 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -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 diff --git a/packages/emmett-expressjs/src/e2e/api.ts b/packages/emmett-expressjs/src/e2e/api.ts index 9cb89ec0..6206868b 100644 --- a/packages/emmett-expressjs/src/e2e/api.ts +++ b/packages/emmett-expressjs/src/e2e/api.ts @@ -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); }, ); @@ -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); }, ); @@ -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); }, ); @@ -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); }, ); @@ -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); }, ); diff --git a/packages/emmett/src/eventStore/eventStore.ts b/packages/emmett/src/eventStore/eventStore.ts index 444c9cb9..db586211 100644 --- a/packages/emmett/src/eventStore/eventStore.ts +++ b/packages/emmett/src/eventStore/eventStore.ts @@ -80,4 +80,4 @@ export type AppendToStreamOptions = { export type AppendToStreamResult = { nextExpectedStreamVersion: StreamVersion; -} | null; +}; diff --git a/tsconfig.json b/tsconfig.json index 3375f08b..89b871c2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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"],