Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

document server router and http #176

Closed

Description

@PatrickJS

document how to include router and http for the server

Activity

  1. simb commented on Feb 5, 2016

    @simb

    Did anything ever happen with this? I am trying to sort out how to get http wired in. My XMLHttpRequest is not available. Not sure what the right path for getting http included in the universal is. Or if that is even the right path.

  2. jeffwhelpley commented on Feb 7, 2016

    @jeffwhelpley
    Contributor

    @simb check out this:

    https://github.com/angular/universal/blob/master/modules/universal/server/src/platform/node.ts#L102

    If you use the angular2-express-engine or angular2-hapi-engine, this part will be done for you, but if you are manually bootstrapping on the server, you will need to set the NodeXHRImpl yourself.

    We are going to include this in the documentation for #258 so closing this issue.

  3. svallory commented on Feb 8, 2016

    @svallory

    @jeffwhelpley damn! Shame I didn't see your message before. Anyways... I am using angular2-express-engine and it wasn't working for me. So I created this: angular2-http-node_backend

  4. jeffwhelpley commented on Feb 8, 2016

    @jeffwhelpley
    Contributor

    @svallory if you are using Universal, you are going to want to use the default http with the Universal NodeXHRImpl provider. The reason is that in Universal we count the number of times http is called during a given server side request. We need to do this because it is the only want to know how long to wait before sending back the response (i.e. if there are 4 http calls during a given server side request, we have to wait for all 4 to resolve plus one change detection cycle before sending back the response.

    Let me know if you have any questions on this.

  5. svallory commented on Feb 9, 2016

    @svallory

    @jeffwhelpley Just checked the code on Universal. I see you guys are using xhr2 package so you get a XmlHttpRequest object on node. THAT is what I replaced by implementing NodeBackend and NodeConnection using native node APIs to perform the request. It's a lighter impl and, if you want, we could bring it inside universal and remove the dependancy.

    I also see other problems:

    1. Current impl of NodeBackend and NodeConnection still uses BrowserXHR
    2. I couldn't find where NodeXhrImpl is actually used (or universal's XHR)
    3. NodeXhrImpl calls Http.get (shouldn't it be the other way around?)

    I'm still kind fresh on ng2 so bare with me if I got something wrong, ok?

  6. PatrickJS commented on Feb 9, 2016

    @PatrickJS
    ContributorAuthor

    @svallory can you make a PR to replace xhr2. NodeXhrImpl is used for templateUrl etc here

    new Provider(XHR, {useClass: NodeXHRImpl}),

  7. svallory commented on Feb 9, 2016

    @svallory

    @gdi2290 I can. I'll work on it next weekend (it's carnival in Brazil :)). All I see in that file is NodeXhrImpl being imported and then exported inside a constant. I don't see it being used.

    Since you mentioned templateUrl, currently relative URL's don't work. Is there a reason not to load it from FS when it's a relative URL?

  8. PatrickJS commented on Feb 9, 2016

    @PatrickJS
    ContributorAuthor

    comment in the other issue #264 as op issue is unrelated.

  9. angular-automatic-lock-bot commented on Sep 4, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  10. locked and limited conversation to collaborators on Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions