BackendStack21 / restana

Restana is a lightweight and fast Node.js framework for building RESTful APIs.
MIT License
467 stars 27 forks source link

Nested routes root path give 404, if querystring is set #112

Closed sookoll closed 2 years ago

sookoll commented 3 years ago

Describe the bug
I have nested routes like this (removing queryParser didn't make any difference, so I assume I can remove it):

import queryParser from 'connect-query'
import bodyParser from 'body-parser'
import cors from 'cors'
import PoisConeroller from './controllers/Pois'

const app = require('restana')()
app.use(queryParser())
app.use(bodyParser.json({ limit: '50mb' }))
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors({
  origin: '*',
  optionsSuccessStatus: 200,
}))
app.use('/v1/pois', PoisConeroller(app.newRouter()))

And PoisController

export default (router) => {
  router
    .get('/', (req, res) => { ... })
    .get('/:provider', (req, res) => { ... })

  return router
}

To Reproduce
Everything works as it should: /v1/pois works /v1/pois/ works /v1/pois/provider works

exept if querystring is set: /v1/pois?format=json do not work, got 404 /v1/pois/?format=json works, but format is not set in req.query /v1/pois/provider?format=json works correctly.

Expected behavior
All examples above should work and query params should be present

schamberg97 commented 2 years ago

I will try to offer a fix this weekend

Drejerdk commented 2 years ago

Any update on this issue?