express icon indicating copy to clipboard operation
express copied to clipboard

Bug with the router class

Open evokerking1 opened this issue 1 year ago • 5 comments

This is my code ``// import the route import { playground } from "@colyseus/playground" // ... const monitor = require("@colyseus/monitor").monitor const express = require("express") const app = express const route = app.Router

// ... route.use("/monitor", monitor)

// bind it as an express middleware route.use("/playground", playground)

app.listen(3000)

which throws this error

$ bun run index.js 478 | end: false 479 | }, fn); 480 | 481 | layer.route = undefined; 482 | 483 | this.stack.push(layer); ^ TypeError: undefined is not an object (evaluating 'this.stack.push') at use (/workspace/colyseus-testing-ground/node_modules/express/lib/router/index.js:483:10) at /workspace/colyseus-testing-ground/index.js:10:7

Bun v1.1.30 (Linux x64) error: script "test" exited with code 1 and the code that throws this error in the /lib/router/index.js line 483 or this.layer.push()

evokerking1 avatar Oct 08 '24 14:10 evokerking1

Whats require-triage label?

evokerking1 avatar Oct 08 '24 16:10 evokerking1

@evokerking1 The Triage Process indicates that it means further triaging is needed to properly classify the issue.

dpopp07 avatar Oct 09 '24 17:10 dpopp07

You wrote const route = app.Router. Is this what's actually in your code? I'd recommend reviewing the docs, which make it clear that you must call Router. That is:

const router = app.Router()

nwalters512 avatar Oct 09 '24 23:10 nwalters512

You wrote const route = app.Router. Is this what's actually in your code? I'd recommend reviewing the docs, which make it clear that you must call Router. That is:

const router = app.Router()

That is all my code.

evokerking1 avatar Oct 10 '24 17:10 evokerking1

Hey @evokerking1 :wave:

Like @nwalters512 pointed out, could you please confirm if the issue persists even after changing,

const route = app.Router

to,

const router = app.Router()

Edit:

Also,

const app = express()

IamLizu avatar Oct 10 '24 17:10 IamLizu

Hey @evokerking1 👋

Like @nwalters512 pointed out, could you please confirm if the issue persists even after changing,

const route = app.Router

to,

Agree! this should work

const router = app.Router()

shivarm avatar Oct 22 '24 14:10 shivarm