davezuko/react-redux-starter-kit创建nodejs api端点.如何? [英] davezuko/react-redux-starter-kit create nodejs api endpoints. How to?

查看:117
本文介绍了davezuko/react-redux-starter-kit创建nodejs api端点.如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始研究一下davezuko的 reactjs-redux样板哪种结构是分形的,我正在寻找一种方法来实现api端点以从mongodb中获取数据.

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.

有哪些方法?要走的路是创建一条新路线并以某种方式与Koa服务器交互?

What are the approaches? The way to go is to create a new route and somehow interact with Koa server?

推荐答案

仔细阅读样板文档,看来作者包括Koa服务器只是为了加载热模块中间件.

Reading over the boilerplate docs, it looks like the author included the Koa server only to load the hot module middleware.

如果您想为mongodb创建自己的API端点,则可能要创建自己的API端点来分开关注点.

If you want to create your own API endpoints for mongodb, you might want to create your own to separate concerns.

从文档中

服务器

此入门工具包随附Koa服务器. 重要的是 请注意,此服务器的唯一目的是为了提供 用于热模块的webpack-dev-middleware和webpack-hot-middleware .使用自定义的Koa应用代替webpack-dev-server 使扩展入门套件使其更容易包含功能 例如API,通用渲染等-一切都不会肿 基础样板.

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.

这篇关于davezuko/react-redux-starter-kit创建nodejs api端点.如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆