问题
I just started to explore a bit this reactjs-redux boilerplate from davezuko which structure is fractal and I search a way to implement api endpoints to fetch data from mongodb.
What are the approaches? The way to go is to create a new route and somehow interact with Koa server?
回答1:
Reading over the boilerplate docs, it looks like the author included the Koa server only to load the hot module middleware.
If you want to create your own API endpoints for mongodb, you might want to create your own to separate concerns.
From the docs:
Server
This starter kit comes packaged with an Koa server. It's important to note that the sole purpose of this server is to provide webpack-dev-middleware and webpack-hot-middleware for hot module replacement. Using a custom Koa app in place of webpack-dev-server makes it easier to extend the starter kit to include functionality such as API's, universal rendering, and more -- all without bloating the base boilerplate.
来源:https://stackoverflow.com/questions/37194292/davezuko-react-redux-starter-kit-create-nodejs-api-endpoints-how-to