router icon indicating copy to clipboard operation
router copied to clipboard

Priority routes not working

Open joshbenaron opened this issue 4 years ago • 2 comments

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

joshbenaron avatar Sep 08 '21 18:09 joshbenaron

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

JeDaYoshi avatar Sep 17 '21 03:09 JeDaYoshi

@joshbenaron would you consider this resolved? :)

peterver avatar Jul 08 '22 14:07 peterver

Resolved!

3imed-jaberi avatar Sep 18 '24 01:09 3imed-jaberi