Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
Overlapping routes are not working in Koa.js

When I call /my/abc/create, I always get status 400 because of the first entrypoint. How can I call second endpoint? I prefer not to change the entrypoint order.

var Router = require('koa-router');

var router = Router();


router.get('/my/:path/:id', (ctx) =>{
    if (isNaN(Number(cox.params.id))) { // if not numeric
        ctx.status = 400;
        return;
    }
    console.log('route id')
})
router.get('/my/:path/create', (ctx) =>{ 
    console.log('route create')
})
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

RESTfully speaking, you wouldn't have a create route at all:

router.get('/my/:path/:id', (ctx) => /* get entity */)
router.post('/my/:path', (ctx) => /* create entity */)
router.patch('/my/:path/:id', (ctx) => /* update entity */)
router.delete('/my/:path/:id', (ctx) => /* delete entity */)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!