BackendStack21 / restana

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

Arrays of url paths #94

Closed schamberg97 closed 4 years ago

schamberg97 commented 4 years ago

Hey there! I was experimenting with restana and found it to be indeed much faster than other frameworks, albeit it was at certain points tricky to migrate towards using it in production. I have pointed the project to colleagues and now we are gradually moving some of our projects to restana. We are mostly using Express in production and for us one of the biggest problems was that restana does not support the use of Arrays for paths. While it is trivial to fix it in our routes, due to the amount of routes in our application, this does not seem practical, because of thousands of routes like that across our projects. Therefore, we are using a patched version of restana that implements this feature. I wanted to make a pull request with the change we've made, but then I thought that I might be missing something. Is there any specific reason why this feature is not implemented?

Examples:

Restana original

app.get('/one/', function (req, res) {
        res.send('something')
})
app.get('/two/', function (req, res) {
        res.send('something')
})

Impractical workaround

function theBestFunction (req,res) {
        res.send('something')
}
app.get('/one/', theBestFunction)
app.get('/two/', theBestFunction)

Desirable

app.get(['/one/', '/two/'], function (req, res) {
        res.send('something')
})
jkyberneees commented 4 years ago

Hi @schamberg97, thanks for reaching out. It is great to know that restana contributes to performance improvements on your environment.

I find your issue totally valid, this feature is currently not implemented/planned in restana. Would you like to follow-up with a PR and we can continue from there? Your contribution is welcome.

Regards

schamberg97 commented 4 years ago

Hold on, will do soon - ~15mins

schamberg97 commented 4 years ago

PR #95