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

182
Views
Nest JS differentiate 2 distinct routes of the same controller

I have a Nest JS application with 2 routes that simply returns the data(preferences) from the database.

I want to create 2 routes:

  1. List item preferences: /api/items
  2. List feature preferences: /api/features

I'm new to NestJS. These 2 routes should be under one module. Is this achievable?

The 2nd route works but I get an error saying 404 Not Found.

@Module({
  controllers: ['PreferenceController'],
  providers: ['PreferenceService']
})
@Controller()
export class PreferenceController{
    constructor(private readonly preferenceService: PreferenceService) {}

    @Get('preference/:x/:y/:z')
    getItem(@Param() param) {
        return this.preferenceService.getItem(param);
    }

    @Get(':id')
    getFeature(@Param() param) {
        return this.preferenceService.getFeature(param);
    }
}
routes = [
   path: '/api',
   children: [
     {
       path: '/items',
       module: 'PreferenceModule'
     },
     { 
       path: '/features',
       module: 'PreferenceModule'
     }
   ]
]
about 4 years ago · Juan Pablo Isaza
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!