Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route cannot be reused with different path #12

Closed
yarsky-tgz opened this issue Feb 6, 2020 · 3 comments
Closed

Route cannot be reused with different path #12

yarsky-tgz opened this issue Feb 6, 2020 · 3 comments
Labels
good first issue Good for newcomers

Comments

@yarsky-tgz
Copy link
Member

We found such hackish solution for now (oldRoute is function which configures router):

const router = new Route();
app.use('/auth/api', router);
oldRoute(router);
app.use('/', router);
oldRoute(router);

waiting for better solution

@dalisoft dalisoft transferred this issue from nanoexpress/legacy Feb 8, 2020
@dalisoft dalisoft transferred this issue from another repository Mar 3, 2020
@dalisoft dalisoft added bug Something isn't working good first issue Good for newcomers wontfix This will not be worked on labels Mar 3, 2020
@dalisoft dalisoft pinned this issue Mar 3, 2020
@dalisoft dalisoft changed the title Router reusage with different path Route cannot be used more than once Mar 3, 2020
@dalisoft dalisoft changed the title Route cannot be used more than once Route cannot be reused with different path Mar 3, 2020
@dalisoft dalisoft unpinned this issue Jul 14, 2020
@dalisoft
Copy link
Member

@yarsky-tgz Hi.
Currently solution is using connect as workaround, but may impact performance.
Route in nanoexpress isn't designed to use more than once, it's possible to fix it, but performance will drops and becomes like connect middleware + nanoexpress performance.

Try like this

const router = connect();

// Now it's like Express API, exactly isn't working nanoexpress Layers anymore
// and `async` functions doesn't work like nanoexpress and WebSocket doesn't supports
router.get('/', (req, res) => {
res.send();
});

app.use('/auth/api', router);
app.use('/', router);

Thanks to @mrauhu for this solution

@dalisoft
Copy link
Member

Hi @yarsky-tgz

Please try nanoexpress@6.x aka next version.
I hope it will work for your case, i got it working on some routes at cost of 5% performance drop, no i think it's not a lot of loss.

@dalisoft
Copy link
Member

It's works on nanoexpress v8 release and seems enough stable as i'm used this on production, works fine

@dalisoft dalisoft removed bug Something isn't working wontfix This will not be worked on labels Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants