keystonejs / universal-keystone-boilerplate

⚠️ Archived - Legacy Keystone.JS boilerplate for Universal JavaScript projects using React.
MIT License
34 stars 10 forks source link

Add universal routing to Keystone proper. #32

Closed ericelliott closed 8 years ago

ericelliott commented 8 years ago

Having a little trouble here.

I got universal routing working with React in the universal-keystone-boilerplate and made a factory that takes react-router-routes and returns an express router.

The idea is to move this capability into Keystone core and use a new component routes option in Keystone.init() to configure React routes to enable universal Routing with React in Keystone apps.

However, when I try to move this into Keystone proper, the routes are 404. );

See my component routes fork.

The factory is in createComponentRouter.js.

I'm attempting to use the factory in createApp.js:

    // Configure component routes
    if (keystone.get('component routes')) {
        app.use('/', createComponentRouter(keystone.get('component routes')));
    }

I have verified that keystone.get('component routes') returns the expected object, and I have tried moving the app.use() call up above the application routes config here:

    // Configure application routes
    if ('function' === typeof keystone.get('routes')) {
        keystone.get('routes')(app);
    }

Don't want to waste too much time stuck on this. Any ideas?

Reproduce

To test this, you can clone the universal-keystone-boilerplate and follow the getting started guide. npm install and npm test to verify that you've got everything set up correctly.

The tests on master should pass.

Then check out the move-component-routing branch and replace the keystone directory in node_modules with the component-routes keystone fork.

Actual Result

Run the tests in the boilerplate again, and you should see the 404 fails.

Expected Result

All tests should pass.

See also