Giter Club home page Giter Club logo

koa-web-kit's Issues

关于路由代理修改确认

在使用代理时,我本地有一些运行出问题,进行了下面的修改,烦请确认:
1.在routes/proxy.js中,修改
const apiProxy = new HttpClient({ endPoint, prefix });

const apiProxy = new HttpClient({ endPoint: endPoint, prefix: prefix });

2.services/HttpClient.js 方法 _finalizeRequestOptions 修改如下
`_finalizeRequestOptions(options = {}) {
let optionPrefix = options.prefix || this.options.prefix;

// TODO: a path rewrite could be better
if (isCustomAPIPrefix && optionPrefix) {
  let optionEndPoint = options.endPoint || this.options.endPoint;
  let endPointUrl = new URL(optionEndPoint);
  options.headers.host = endPointUrl.host;

  options.url = options.url.replace(new RegExp(`^${optionPrefix}`), '');

}
return options;

}`

yarn install 之后 ,run dev 出现了这个问题。。

(node:58220) UnhandledPromiseRejectionWarning: TypeError: res.getHeader is not a function
    at processRequest (/Users/blockmood/Desktop/pc/node_modules/webpack-dev-middleware/lib/middleware.js:82:18)
    at ready (/Users/blockmood/Desktop/pc/node_modules/webpack-dev-middleware/lib/util.js:51:12)
    at handleRequest (/Users/blockmood/Desktop/pc/node_modules/webpack-dev-middleware/lib/util.js:167:5)
    at Promise (/Users/blockmood/Desktop/pc/node_modules/webpack-dev-middleware/lib/middleware.js:44:7)
    at new Promise (<anonymous>)
    at middleware (/Users/blockmood/Desktop/pc/node_modules/webpack-dev-middleware/lib/middleware.js:43:12)
    at Promise (/Users/blockmood/Desktop/pc/node_modules/koa-webpack/lib/middleware.js:28:9)
    at new Promise (<anonymous>)
    at /Users/blockmood/Desktop/pc/node_modules/koa-webpack/lib/middleware.js:27:20
    at dispatch (/Users/blockmood/Desktop/pc/node_modules/koa/node_modules/koa-compose/index.js:42:32)
    at createGenerator (/Users/blockmood/Desktop/pc/node_modules/koa-convert/index.js:24:16)
    at createGenerator.next (<anonymous>)
    at Object.<anonymous> (/Users/blockmood/Desktop/pc/node_modules/koa-history-api-fallback/lib/index.js:104:5)
    at Generator.next (<anonymous>)
    at onFulfilled (/Users/blockmood/Desktop/pc/node_modules/co/index.js:65:19)
    at /Users/blockmood/Desktop/pc/node_modules/co/index.js:54:5
(node:58220) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:58220) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Better Docker support

the current Dockerfile is just some kine of demo, which is not production ready.
TODO:

  • Docker integration for local development
  • Docker integration for production deployment
  • Improve the way to pass config into docker container for both dev and prod
  • docker-compose support

命令npm run deploy 如何ssr运行?

您好
再问个问题,如果想要服务器渲染(ssr)的方式运行,应执行什么命令?

我运行了npm run deploy后,查看源码还是JS进行页面渲染的。

exec this command npm run dev:ssr error

$ npm run dev:ssr

[email protected] dev:ssr /myhome/koa-web-kit-2.8.2
cross-env ENABLE_HMR=0 CSS_MODULES=0 ENABLE_SSR=1 npm-run-all -p watch watch:ssr start

[email protected] watch /myhome/koa-web-kit-2.8.2
webpack --watch --progress --hide-modules --config config/webpack.config.dev.js

[email protected] watch:ssr /myhome/koa-web-kit-2.8.2
npm run ssr -- --watch

[email protected] start /myhome/koa-web-kit-2.8.2
nodemon --trace-warnings server.js

[email protected] ssr /myhome/koa-web-kit-2.8.2
webpack --progress --config config/webpack.config.ssr.js "--watch"

[nodemon] 1.18.10
[nodemon] to restart at any time, enter rs
[nodemon] watching: /myhome/koa-web-kit-2.8.2/api//* /myhome/koa-web-kit-2.8.2/config//* /myhome/koa-web-kit-2.8.2/build/node//* /myhome/koa-web-kit-2.8.2/routes//* /myhome/koa-web-kit-2.8.2/utils//* /myhome/koa-web-kit-2.8.2/services//* app-config.js server.js
[nodemon] starting node --trace-warnings server.js
Using [/myhome/koa-web-kit-2.8.2/config/app-config.js] as basic app configuration
Using [/myhome/koa-web-kit-2.8.2/config/app-config.js] as basic app configuration
Using [/myhome/koa-web-kit-2.8.2/config/app-config.js] as basic app configuration
10% building 0/0 modules 0 active
webpack is watching the files…

(node:56855) DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead
10% building 0/0 modules 0 active
webpack is watching the files…

10% building 0/1 modules 1 active ...ctjs/ 10% building 0/1 modules 1 active .../reactjs/koa-web-kit-2.8.2 15% building 43/73 modules 30 active ...ages/School/schoolInfo/stuPlan/index.js/myhome/koa-web-kit-2.8.2/node_modules/antd/dist/antd.css:15
body {
^

SyntaxError: Unexpected token {
at new Script (vm.js:83:7)
at createScript (vm.js:267:10)
at Object.runInThisContext (vm.js:319:10)
at Module._compile (internal/modules/cjs/loader.js:684:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:657:17)
at require (internal/modules/cjs/helpers.js:22:18)
15% building 47/73 modules 26 active ...ages/School/schoolInfo/stuPlan/index.js[nodemon] app crashed - waiting for file changes before starting...
15% building 47/90 modules 43 active .../pages/School/schoolInfo/yishu/index.js 19% building 82/111 module 16% building 50/103 modules 53 active ....2/node_modules/redux-thunk/es/index.js 20% building 85/111 modul 19% building 81/117 modules 36 active ...modules/core-js/modules/_regexp-exec.js 20% building 91/144 modul 34% building 200/234 modules 34 active ...kit-2.8.2/node_modules/ 71% after chunk graph WebAssemblyModules 34% building 201/234 modules 33 active ...kit-2.8.2/node_modules/antd/es/index.js 87% record chunks Record 34% building 204/234 modules 30 active ...kit-2.8.2/node_modules/antd 88% content hashing JavascriptModule 35% building 215/254 modules 39 active ...ol/schoolInfo/schoolView/viewContent.jsHash: 81441c461dd449737536
Version: webpack 4.28.4
Time: 2705ms
Built at: 2019/02/20 下午5:41:32
Asset Size Chunks Chunk Names
ssr.js 2.56 MiB ssr [emitted] ssr
Entrypoint ssr = ssr.js
[./build/app/manifest.json] 368 bytes {ssr} [built]
[./build/react-loadable.json] 1.55 MiB {ssr} [built]
[./src/AppRoutes.jsx] 1.52 KiB {ssr} [built]
[./src/modules/context.js] 360 bytes {ssr} [built]
[./src/pages/routes.js] 10 KiB {ssr} [built]
[./src/ssr/index.js] 5.14 KiB {ssr} [built]
[@babel/runtime/helpers/interopRequireDefault] external "@babel/runtime/helpers/interopRequireDefault" 42 bytes {ssr} [built]
[@loadable/component] external "@loadable/component" 42 bytes {ssr} [built]
[core-js/modules/web.dom.iterable] external "core-js/modules/web.dom.iterable" 42 bytes {ssr} [built]
[prop-types] external "prop-types" 42 bytes {ssr} [built]
[react] external "react" 42 bytes {ssr} [built]
[react-dom/server] external "react-dom/server" 42 bytes {ssr} [built]
[react-loadable] external "react-loadable" 42 bytes {ssr} [built]
[react-loadable/webpack] external "react-loadable/webpack" 42 bytes {ssr} [built]
[react-router-dom] external "react-router-dom" 42 bytes {ssr} [built]
+ 203 hidden modules
36% building 218/258 modules 40 active ...-2.8.2/src/components/ziliao/index.scss[nodemon] restarting due to changes...
[nodemon] starting node --trace-warnings server.js
38% building 239/282 modules 43 active ...-2.8.2/src/components/Footer/index.scssUsing [/myhome/koa-web-kit-2.8.2/config/app-config.js] as basic app configuration
68% building 591/604 modules 13 active ...2/node_modules/zrender/lib/core/util.js/myhome/koa-web-kit-2.8.2/node_modules/antd/dist/antd.css:15
body {
^

SyntaxError: Unexpected token {
at new Script (vm.js:83:7)
at createScript (vm.js:267:10)
at Object.runInThisContext (vm.js:319:10)
at Module._compile (internal/modules/cjs/loader.js:684:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:657:17)
at require (internal/modules/cjs/helpers.js:22:18)
[nodemon] app crashed - waiting for file changes before starting...nearGradient.js
95% emitting ManifestPlugin(node:56855) DeprecationWarning: Chunk.forEachModule: Use for(const module of chunk.modulesIterable) instead
Hash: aa624165a41dea2ef279
Version: webpack 4.28.4
Time: 10269ms
Built at: 2019/02/20 下午5:41:39
Asset Size Chunks Chunk Names
app.css 661 KiB app [emitted] app
app.css.map 814 KiB app [emitted] app
app.js 11.3 MiB app [emitted] app
app.js.map 11.1 MiB app [emitted] app
assets/static/favicon.ico 16.6 KiB [emitted]
assets/static/logo.svg 2.61 KiB [emitted]
favicon.ico 16.6 KiB [emitted]
index-backup.html 1.16 KiB [emitted]
manifest.json 368 bytes [emitted]
runtime.js 6.08 KiB runtime [emitted] runtime
runtime.js.map 5.98 KiB runtime [emitted] runtime
Entrypoint app = runtime.js runtime.js.map app.css app.js app.css.map app.js.map

ERROR in ./src/App.jsx
Module not found: Error: Can't resolve 'react-addons-css-transition-group' in '/myhome/koa-web-kit-2.8.2/src'
@ ./src/App.jsx 16:60-104
@ ./src/index.js
Hash: 40799cda9bbd9526a833
Version: webpack 4.28.4
Time: 109ms
Built at: 2019/02/20 下午5:41:40
Asset Size Chunks Chunk Names
ssr.js 2.56 MiB ssr [emitted] ssr
Entrypoint ssr = ssr.js
[./build/react-loadable.json] 1.55 MiB {ssr} [built]
+ 217 hidden modules
[nodemon] restarting due to changes...
[nodemon] starting node --trace-warnings server.js
Using [/myhome/koa-web-kit-2.8.2/config/app-config.js] as basic app configuration
/myhome/koa-web-kit-2.8.2/node_modules/antd/dist/antd.css:15
body {
^

SyntaxError: Unexpected token {
at new Script (vm.js:83:7)
at createScript (vm.js:267:10)
at Object.runInThisContext (vm.js:319:10)
at Module._compile (internal/modules/cjs/loader.js:684:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:657:17)
at require (internal/modules/cjs/helpers.js:22:18)
[nodemon] app crashed - waiting for file changes before starting...

webpack.config.node.js文件作用?

请问下,webpack.config.node.js的作用是将koa的代码压缩打包么? 如何是压缩打包,那压缩打包后,是直接启动打包后的文件么?

关于dev问题

这套代码有配置好开发的dev环境吗,好像yarn dev后不会监听文件的变化重新打包

Add dotenv support

add support for using dotenv to pass app configurations, also should be compatible with legacy app-config.js

  • API_ENDPOINTS can accept simple url string, so it can be better compatiable with dotenv
  • add dotenv support

报websocket的错误

有时候会报错 怎么去掉这个报错?
socket.js:19 WebSocket connection to 'ws://localhost:63065/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

代理返回blob对象

您好,使用您的框架,我遇到个问题: get请求,返回的数据如果是blob对象的话,代理中会对齐进行编码,前端接受到的数据 将不是一个blob对象,这个如何解决?
C46F95ADE405E7D21FA43E418881C19B

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.