koajs / router

Router middleware for Koa. Maintained by @forwardemail and @ladjs.
MIT License
849 stars 174 forks source link

Priority routes not working #131

Open joshbenaron opened 2 years ago

joshbenaron commented 2 years ago

node.js version: 16.8

@koa/router version: 10.1.1

koa version: 2.13.1

Code sample:

export const router = new Router()
  .get("/ping", ping)
  .get("/public", getPublic)
  .get("/account/balance", getUserBalance)
  .get("/peers", getPeers)
  .get("/peers/random/:count", getRandomPeers)
  .post("/tx", postTxRateLimiter, initialChecks, fileUpload, verifyUpload, sendSignedResponse)
  .head("/:txId", getTx)
  .get("/:txId", getTx)
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  // @ts-ignore
  .post("/newTx", rateLimiter, jsonBodyParser, newTx);

Expected Behavior:

When I go to GET /ping - I should see a specific output

Actual Behavior:

GET /ping is going to GET /:txId

JeDaYoshi commented 2 years ago

Do you have a next() on your /ping middleware? If you don't want any other routes to be executed, you should remove it.

peterver commented 2 years ago

@joshbenaron would you consider this resolved? :)