Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    dontwork
    @dontwork
    Have you done it?
    Stephan Hoyer
    @StephanHoyer
    function baseHtml(content) {
       return '<html><body>' + content + '</body></html>'
    }
    
    each(routes, function (module, route) {
      var onmatch = module.onmatch || (() => module)
      var render = module.render || identity
      app.get(route, function (req, res, next) {
        res.type('html')
        Promise.resolve()
          .then(() => onmatch(req.params, req.url))
          .then(render)
          .then(toHtml)
          .then(baseHtml)
          .then(res.send.bind(res))
          .catch(next)
      })
    })
    
    module.exports = app
    that's how I just did it in the isomorphic example
    toHtml is mithril-node-render
    dontwork
    @dontwork
    Thanks I will take a proper look later
    Stephan Hoyer
    @StephanHoyer
    isomorphic example is ready for 1.0 release. Would love to get some feedback https://github.com/StephanHoyer/mithril-isomorphic-example
    dontwork
    @dontwork
    should m.request be run on the server?
    Stephan Hoyer
    @StephanHoyer
    no
    Hendrik Roth
    @HendrikRoth
    i use isomorphic fetch for this task.
    Stephan Hoyer
    @StephanHoyer
    it does not work on the server. thats why I created store-facade
    dontwork
    @dontwork
    what if the api is on another server
    Stephan Hoyer
    @StephanHoyer
    than you have to use a server side ajax lib
    like isomorphic fetch
    like @HendrikRoth
    dontwork
    @dontwork
    as a replacement for m.request?
    Hendrik Roth
    @HendrikRoth
    yes
    Stephan Hoyer
    @StephanHoyer
    I would probably use https://github.com/mzabriskie/axios for both
    Hendrik Roth
    @HendrikRoth
    i don't use m.request
    dontwork
    @dontwork
    i hadnt realised this
    i was getting an error from the xmlhttpreq mock
    Stephan Hoyer
    @StephanHoyer
    I currently use superagent for server side and m.request for client
    dontwork
    @dontwork
    thanks for the advice and lib recc, i will take a look in a min
    you like axios though?
    Stephan Hoyer
    @StephanHoyer
    havent used it. But a lot of people got back to it after trying fetch
    Hendrik Roth
    @HendrikRoth
    i used isomorphic fetch to drop the client side fetch if it is native supported everywhere
    dontwork
    @dontwork
    so is there no desire to make m.request isomorphic
    i guess its impossible because it relies on xhr?
    Stephan Hoyer
    @StephanHoyer
    that would be an option
    dontwork
    @dontwork
    just a shame its in the codebase but only works on browser
    especially when mithril-node-render is practically a perfect isomorphic solution
    except requests
    Stephan Hoyer
    @StephanHoyer
    it's pretty much a hyperscript2html converter only
    if you want more, you can easily build it using mnr
    dontwork
    @dontwork
    mnr?
    Stephan Hoyer
    @StephanHoyer
    mithril-node-render
    ;)
    dontwork
    @dontwork
    build what?
    Stephan Hoyer
    @StephanHoyer
    a complete isomorphic setup
    routing is another thing that is not supportet
    dontwork
    @dontwork
    this is what ive done
    im just setting up redux and i will have the whole 'rehydration' thing done
    Stephan Hoyer
    @StephanHoyer
    because erveryone has different opinions on this
    same goes for xhr
    dontwork
    @dontwork
    so its probably a worthless pursuit to develop m.request to an isomorphic solution?
    brb lunch
    Stephan Hoyer
    @StephanHoyer
    but building a server-side m.request should't be that big of deal I think
    dontwork
    @dontwork
    Do you think it would be a welcome addition
    pretty neat