Code Monkey home page Code Monkey logo

Comments (11)

catamphetamine avatar catamphetamine commented on May 21, 2024

Oh, sure, that should be return wait_for_file instead of wait_for_file.
Install the latest version for the fix, it should be working.

So I'm guessing you return a Koa middleware from the server() function, and then .use() that middleware on the main Koa app?
Or is there some way to mount a child Koa application inside a parent Koa application?

Yesterday I've also introduced an extension point for page-server:
https://github.com/halt-hammerzeit/react-isomorphic-render/blob/33906f9f787a0bae88067aae593788a2b09a55dc/source/page-server/web%20server.js#L94-L102
Maybe it can serve your needs too.

from universal-webpack.

adailey14 avatar adailey14 commented on May 21, 2024

Awesome thanks for updating that.

For mounting, I read that you can use koa-mount to mount one koa app within
another as a middleware, but haven't actually tried it yet:
https://github.com/koajs/mount. I am going to try that and if it doesn't
work then return a koa middleware like you said. Ideally koa-mount will
work so I can use your webserver from the react-isomorphic-render project.
I'm trying to stick with your implementation as much as possible, since it
is cleaner than when I do my own.

I will check out the extension point for page-server, I think it may be
very handy.

On Wed, Jul 20, 2016 at 7:04 PM, Nikolay [email protected] wrote:

Oh, sure, that should be return wait_for_file instead of wait_for_file.
Install the latest version for the fix, it should be working.

So I'm guessing your return a Koa middleware from the server() function,
and then .use() that middleware on the main Koa app?
Or is there some way to mount a child Koa application inside a parent Koa
application?

Yesterday I've also introduced an extension point for page-server:

https://github.com/halt-hammerzeit/react-isomorphic-render/blob/33906f9f787a0bae88067aae593788a2b09a55dc/source/page-server/web%20server.js#L94-L102
Maybe it can serve your needs too.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#21 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABHVMTMYRYUXagVOcxrvJhqgefUBQYizks5qXrecgaJpZM4JRS22
.

from universal-webpack.

catamphetamine avatar catamphetamine commented on May 21, 2024

Ok.
I might also give the current page-server architecture a thought and maybe export a server-render function which would basically be the already present rendering function
https://github.com/halt-hammerzeit/react-isomorphic-render/blob/master/source/page-server/render.js#L18
That function would return a Promise resolving to HTML markup, and so it could be usable with anything be it Koa, Express or any other library.
That can be the task for tomorrow.

from universal-webpack.

adailey14 avatar adailey14 commented on May 21, 2024

Yes I think that would be good.

On Wed, Jul 20, 2016 at 7:21 PM, Nikolay [email protected] wrote:

Ok.
I might also give the current page-server architecture a thought and
maybe export a server-render function which would basically be the
already present rendering function

https://github.com/halt-hammerzeit/react-isomorphic-render/blob/master/source/page-server/render.js#L18
That function would return a Promise, and so it could be usable with
anything be it Koa, Express or any other library.
That can be the task for tomorrow.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#21 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABHVMV3wejw_FxnQjWsLLbIOFOJXC2v4ks5qXrufgaJpZM4JRS22
.

from universal-webpack.

adailey14 avatar adailey14 commented on May 21, 2024

Hi again. I am running into trouble, I think because halt-hammerzeit/web-service is using koa ^2.0.0, while halt-hammerzeit/react-isomorphic-render is using koa 1.1.2. koa-mount's current release is support koa 1.x, and they have a "next" branch supporting 2.x.

I will see if I can get this to work, but it might be worth updating react-isomorphic-render to koa 2.x at some point for consistency.

from universal-webpack.

catamphetamine avatar catamphetamine commented on May 21, 2024

I migrated react-isomorphic-render to Koa v2 recently, have you updated the package?

from universal-webpack.

adailey14 avatar adailey14 commented on May 21, 2024

Oh oops I didn't notice that, thanks!

from universal-webpack.

adailey14 avatar adailey14 commented on May 21, 2024

FYI I just got everything to work, mounting the page-server within the web-service for production.

3 "gotchas" were:

  1. I had to use koa-mount@next version to support koa 2.x
  2. I had to pass detect_locale: true option when creating web-service, otherwise the mounted page-server would crash, since the ctx object passed through from the parent koa application did not have the getLocaleFromQuery() function.
  3. I had to make page-server/start export a function to generate the server like this:
    export default () => server(configuration, settings);
    And then call that function in page-server/web server.js and web-server/web server.js
    Otherwise the server would get started multiple times since I need to import it in both page-server/web server.js and web-server/web server.js.

from universal-webpack.

catamphetamine avatar catamphetamine commented on May 21, 2024
  1. Yeah, that's a little gotcha
  2. Oh, I get it. I was going to remove that option first but seems that it has its uses. Anyway I'll extract routing in a separate middleware soon. These two days were non-stop coding and debugging (mostly fixing react-isomorphic-render bugs)
  3. Didn't get the idea without the code, but I guess I don't have to.

from universal-webpack.

catamphetamine avatar catamphetamine commented on May 21, 2024

Extracted server-side rendering into an exported render function in the latest version of the package.
https://github.com/halt-hammerzeit/react-isomorphic-render#without-proxying

from universal-webpack.

catamphetamine avatar catamphetamine commented on May 21, 2024

Removed preferred_locale from render function parameters.
Now it only takes the same parameters as webpage server + request original HTTP request.
preferred_locale is not passed in this case and it's up to the developer to detect the preferred locale.

from universal-webpack.

Related Issues (20)

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.