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

Middleware doesn't work with createFarceRouter #153

Closed
cutamar opened this issue Apr 17, 2020 · 7 comments
Closed

Middleware doesn't work with createFarceRouter #153

cutamar opened this issue Apr 17, 2020 · 7 comments

Comments

@cutamar
Copy link

cutamar commented Apr 17, 2020

Seems this doesn't work with createFarceRouter. I get the following error:
TypeError: matcher.routeConfig.forEach is not a function in createMatcherNamedRoutesMiddleware.js:59

@taion
Copy link
Contributor

taion commented Apr 18, 2020

Do you have more details on how you're using this?

@cutamar
Copy link
Author

cutamar commented Apr 19, 2020

@taion same as in this sample https://github.com/relay-tools/found-relay#router-configuration
set names for the routes, and added the middleware from found-named-routes to historyMiddlewares. That's all I did

@taion
Copy link
Contributor

taion commented Apr 19, 2020

What are you passing in for the route config to createNamedRoutesMiddleware? If you're using JSX routes, then it should be the output of makeRouteConfig.

@cutamar
Copy link
Author

cutamar commented Apr 19, 2020

I missed the fact, that createNamedRoutesMiddleware needs the routeConfig, and used the middleware function direclty. Fixed it now, and works really well. Thanks for the fast support, and sorry for wasting your time, by not reading the instructions carefully.

@cutamar cutamar closed this as completed Apr 19, 2020
@taion
Copy link
Contributor

taion commented Apr 19, 2020

don't worry about it! i'm clarifying things in the README a bit in #154

@cutamar
Copy link
Author

cutamar commented Apr 19, 2020

Adding types would also be a big help for all typescript users, then errors like this couldn't happen. For this package I wrote the type def myself, and it looks like this:

declare module 'found-named-routes' {
    import Middleware from 'farce';
    import RouteConfig from 'found';

    const createNamedRoutesMiddleware = (routeConfig: RouteConfig) => Middleware;
}

Only problem is, that it depends on farce in this case.

@taion
Copy link
Contributor

taion commented Apr 20, 2020

You're right. I need to find time to get 4Catalyzer/farce#175 merged, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants