Skip to content

Commit 3465b2b

Browse files
authored
Fix Simulation Log From Express v5 Breaking Change (#332)
1 parent 4b1cd64 commit 3465b2b

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

.changes/express-stack-sim-log.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@simulacrum/foundation-simulator": patch:bug
3+
---
4+
5+
Fix handling of simulation route log for extended routes which changed and broke in the upgrade to express v5. It changed where the nesting of that route information.

packages/foundation/example/extensiveServer/extend-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const extendRouter = (
55
router: Router,
66
simulationStore: ExtendedSimulationStore
77
) => {
8-
router.get("extended-route", (req, res) => {
8+
router.get("/extended-route", (req, res) => {
99
let dogs = simulationStore.schema.dogs.select(
1010
simulationStore.store.getState()
1111
);

packages/foundation/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ export function createFoundationSimulationServer<
177177
if (extendRouter) {
178178
extendRouter(app, simulationStore);
179179

180-
if (app?._router?.stack) {
181-
const layers: IRoute[] = app._router.stack
182-
.map((stack: ILayer) => stack.route)
183-
.filter(Boolean);
180+
if (app?.router?.stack) {
181+
const layers: IRoute[] = app.router
182+
.stack!.map((stack: ILayer) => stack.route)
183+
.filter((r): r is IRoute => Boolean(r));
184184

185185
const simulationRoutes = [];
186186
for (let layer of layers) {

0 commit comments

Comments
 (0)