Skip to content

Commit

Permalink
Merge pull request #71 from TomKaltz/fix-70
Browse files Browse the repository at this point in the history
fix #70
  • Loading branch information
Rotorsoft authored Apr 9, 2024
2 parents e3613c7 + db0b364 commit bd97453
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions libs/eventually-express/src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
type RestProjectionQuery,
type Schema,
type Snapshot,
type State
type State,
decamelize
} from "@rotorsoft/eventually";
import type { NextFunction, Request, Response } from "express";

Expand Down Expand Up @@ -75,7 +76,7 @@ export const getHandler =
};

export const commandHandler =
(factory: CommandHandlerFactory, name: string, withEtag: boolean) =>
(factory: CommandHandlerFactory, name: string, reducible: boolean) =>
async (
req: Request<{ id: string }, any, State, never> & {
actor?: Actor;
Expand All @@ -86,10 +87,10 @@ export const commandHandler =
try {
const { id } = req.params;
const ifMatch = req.headers["if-match"] || undefined;
const expectedVersion = withEtag && ifMatch ? +ifMatch : undefined;
const expectedVersion = reducible && ifMatch ? +ifMatch : undefined;
const { actor } = req;
const snap = await client().command(factory, name, req.body, {
stream: id,
stream: reducible ? id : decamelize(factory.name),
expectedVersion,
actor
});
Expand Down

0 comments on commit bd97453

Please sign in to comment.