From 367b08a5a79cfe168dd91aee718ad282a3e750f7 Mon Sep 17 00:00:00 2001 From: Jacob Bolda Date: Fri, 31 May 2024 22:14:08 -0500 Subject: [PATCH] pass simulationStore directly to handlers --- packages/foundation/example/server.ts | 12 +++--------- packages/foundation/index.ts | 10 ++++------ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/packages/foundation/example/server.ts b/packages/foundation/example/server.ts index ab12d2f3..d85387cd 100644 --- a/packages/foundation/example/server.ts +++ b/packages/foundation/example/server.ts @@ -78,20 +78,14 @@ startServerStandalone({ openapiSchemaFromRealEndpoint, openapiSchemaWithModificationsForSimulation, ], - handlers({ simulationStore }) { + handlers({ store, schema, actions }) { return { getDogs: (c, req, res) => { - let dogs = simulationStore.schema.boop.select( - simulationStore.store.getState() - ); + let dogs = schema.boop.select(store.getState()); res.status(200).json({ dogs }); }, putDogs: (c, req, res) => { - simulationStore.store.dispatch( - simulationStore.actions.updater( - simulationStore.schema.boop.increment() - ) - ); + store.dispatch(actions.updater(schema.boop.increment())); res.sendStatus(200); }, }; diff --git a/packages/foundation/index.ts b/packages/foundation/index.ts index ddd6ea25..66b60fa5 100644 --- a/packages/foundation/index.ts +++ b/packages/foundation/index.ts @@ -31,11 +31,9 @@ export async function startServerStandalone< }: { openapi?: { document: Document | [Document, RecursivePartial]; - handlers: ({ - simulationStore, - }: { - simulationStore: SimulationStoreContext; - }) => Record>; + handlers: ( + simulationStore: SimulationStoreContext + ) => Record>; apiRoot?: string; }; port: number; @@ -74,7 +72,7 @@ export async function startServerStandalone< } } }; - handlerObjectRegistration(handlers({ simulationStore })); + handlerObjectRegistration(handlers(simulationStore)); api.register({ validationFail: (c, req, res) =>