Skip to content

Commit

Permalink
feat(build): express to nestjs in ssr (valor-software#5152)
Browse files Browse the repository at this point in the history
* feat(build): change express to nestjs in ssr app
* fix(demo): location is not defined
  • Loading branch information
Domainv authored Apr 7, 2019
1 parent 1ac64b9 commit 2b7a2fd
Show file tree
Hide file tree
Showing 10 changed files with 1,323 additions and 530 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
on: development
# deploy to ngx-universal.herokuapp.com/
- stage: deploy
script: npm run build:dynamic
script: npm run build:ssr
before_deploy:
- cd ./demo/dist
deploy:
Expand Down
17 changes: 15 additions & 2 deletions demo/src/app/common/top-menu/top-menu.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AfterViewInit, Component, Inject, PLATFORM_ID } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { AfterViewInit, Component } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { NavigationEnd, Router } from '@angular/router';

@Component({
Expand All @@ -10,6 +11,7 @@ export class TopMenuComponent implements AfterViewInit {
appUrl: string;
appHash: string;
currentVersion: string;
isBrowser: boolean;

previousDocs: {
url: string;
Expand All @@ -20,9 +22,20 @@ export class TopMenuComponent implements AfterViewInit {
isLocalhost = false;
needPrefix = false;

constructor(private router: Router, private http: HttpClient) {}
constructor(
@Inject(PLATFORM_ID) platformId: number,
private http: HttpClient,
private router: Router
) {
this.isBrowser = isPlatformBrowser(platformId);
}


ngAfterViewInit(): any {
if (!this.isBrowser) {
return;
}

// todo: remove this sh**
if (typeof window !== 'undefined') {
this.isLocalhost = location.hostname === 'localhost';
Expand Down
Loading

0 comments on commit 2b7a2fd

Please sign in to comment.