Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

Commit

Permalink
Merge b45c95d into 9524932
Browse files Browse the repository at this point in the history
  • Loading branch information
akanass committed Oct 31, 2018
2 parents 9524932 + b45c95d commit 3f5a1a4
Show file tree
Hide file tree
Showing 14 changed files with 2,470 additions and 1,077 deletions.
3 changes: 0 additions & 3 deletions .istanbul.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.0.0
11.0.0
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pretest:
@node ./node_modules/.bin/tslint -p ./tsconfig.json "./src/**/*.ts" "./test/**/*.ts"
test:
@node ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha "./test/**/*.ts"
@node node_modules/.bin/jest
coveralls:
cat ./coverage/lcov.info | node ./node_modules/.bin/coveralls
tsc:
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ This is a [Hapiness](https://github.com/hapinessjs/hapiness) Engine for running

This story will show you how to set up Universal bundling for an existing `@angular/cli`.

We support actually `@angular` `@6.1.8` and next so you must upgrade all packages inside your project.
We support actually `@angular` `@7.0.1` and next so you must upgrade all packages inside your project.

We use `yarn` as package manager.

Expand Down Expand Up @@ -551,6 +551,11 @@ To set up your development environment:
[Back to top](#table-of-contents)

## Change History
* v7.0.0 (2018-10-31)
* `Angular v7.0.1+`
* Migrate tests to [jest](https://jestjs.io/en/) and [ts-jest](https://kulshekhar.github.io/ts-jest/)
* Code refactoring
* Documentation
* v6.2.0 (2018-09-24)
* `Angular v6.1.8+`
* Latest packages' versions
Expand Down
9 changes: 9 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
collectCoverage: true,
coverageDirectory: './coverage',
testMatch: ['**/test/**/*.(test|spec).ts?(x)'],
clearMocks: true,
verbose: true
};
61 changes: 30 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "@hapiness/ng-universal",
"version": "6.2.0",
"version": "7.0.0",
"description": "This is a Hapiness Engine for running Angular Apps on the server for server side rendering.",
"main": "index.js",
"types": "index.d.ts",
"private": false,
"scripts": {
"test": "make test",
"pretest": "make pretest",
"pretest": "make clean && make pretest",
"coveralls": "make coveralls",
"packaging": "make packaging",
"prebuild": "make pretest && make test && make clean",
"prebuild": "make clean && make pretest && make test",
"build": "make tsc && make ngc-tokens",
"postbuild": "make packaging"
},
Expand Down Expand Up @@ -75,46 +75,45 @@
},
"homepage": "https://github.com/hapinessjs/ng-universal-module#readme",
"dependencies": {
"@types/node": "^10.10.3",
"@types/node": "^10.12.0",
"rxjs-compat": "~6.2.2"
},
"devDependencies": {
"@angular/animations": "^6.1.8",
"@angular/common": "^6.1.8",
"@angular/compiler": "^6.1.8",
"@angular/compiler-cli": "^6.1.8",
"@angular/core": "^6.1.8",
"@angular/http": "^6.1.8",
"@angular/platform-browser": "^6.1.8",
"@angular/platform-browser-dynamic": "^6.1.8",
"@angular/platform-server": "^6.1.8",
"@hapiness/core": "^1.5.4",
"@nguniversal/module-map-ngfactory-loader": "^6.1.0",
"@angular/animations": "^7.0.1",
"@angular/common": "^7.0.1",
"@angular/compiler": "^7.0.1",
"@angular/compiler-cli": "^7.0.1",
"@angular/core": "^7.0.1",
"@angular/http": "^7.0.1",
"@angular/platform-browser": "^7.0.1",
"@angular/platform-browser-dynamic": "^7.0.1",
"@angular/platform-server": "^7.0.1",
"@hapiness/core": "^1.5.5",
"@nguniversal/module-map-ngfactory-loader": "^7.0.2",
"@types/fs-extra": "^5.0.4",
"@types/jest": "^23.3.8",
"coveralls": "^3.0.2",
"fs-extra": "^7.0.0",
"istanbul": "^1.1.0-alpha.1",
"mocha": "^5.2.0",
"mocha-typescript": "^1.1.17",
"jest": "^23.6.0",
"rimraf": "^2.6.2",
"rxjs": "^6.3.2",
"rxjs": "^6.3.3",
"ts-jest": "^23.10.4",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"typescript": "~2.9.2",
"unit.js": "^2.0.0",
"typescript": "^3.1.3",
"zone.js": "^0.8.26"
},
"peerDependencies": {
"@angular/compiler": "^6.1.8",
"@angular/core": "^6.1.8",
"@angular/platform-server": "^6.1.8",
"@hapiness/core": "^1.5.4",
"@hapiness/ng-universal-transfer-http": "^8.1.1",
"@nguniversal/module-map-ngfactory-loader": "^6.1.0",
"rxjs": "^6.3.2",
"ts-loader": "^5.2.0",
"webpack": "^4.19.1",
"webpack-cli": "^3.1.1"
"@angular/compiler": "^7.0.1",
"@angular/core": "^7.0.1",
"@angular/platform-server": "^7.0.1",
"@hapiness/core": "^1.5.5",
"@hapiness/ng-universal-transfer-http": "^9.0.0",
"@nguniversal/module-map-ngfactory-loader": "^7.0.2",
"rxjs": "^6.3.3",
"ts-loader": "^5.2.2",
"webpack": "^4.23.1",
"webpack-cli": "^3.1.2"
},
"engines": {
"node": ">=7.0.0"
Expand Down
29 changes: 15 additions & 14 deletions src/module/routes/universal/get/html.route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { OnGet, Request, Route, ReplyNoContinue, HTTPHandlerResponse } from '@hapiness/core';
import { HTTPHandlerResponse, OnGet, ReplyNoContinue, Request, Route } from '@hapiness/core';
import { NgEngineService } from '../../../services';
import { Response } from 'hapi';
import { Observable, of, merge } from 'rxjs';
import { EMPTY, merge, Observable, of } from 'rxjs';
import { filter, flatMap, map, tap } from 'rxjs/operators';


Expand All @@ -27,9 +27,11 @@ export class GetHtmlUniversalRoute implements OnGet {
* @returns {Observable<any | HTTPHandlerResponse>}
*/
onGet(request: Request, reply: ReplyNoContinue) {
this._ngEngineService.universal(request, reply).pipe(
flatMap(_ => this._replyResponse(request, reply, _))
).subscribe();
this._ngEngineService.universal(request, reply)
.pipe(
flatMap(_ => this._replyResponse(request, reply, _))
)
.subscribe();
}


Expand All @@ -42,7 +44,7 @@ export class GetHtmlUniversalRoute implements OnGet {
* @param {ReplyNoContinue} reply
* @param {any | HTTPHandlerResponse} response
*/
private _replyResponse(request: Request, reply: ReplyNoContinue, response: any | HTTPHandlerResponse): Observable<string> {
private _replyResponse(request: Request, reply: ReplyNoContinue, response: any | HTTPHandlerResponse): Observable<never> {
return of(of(request))
.pipe(
flatMap(obs =>
Expand All @@ -53,9 +55,7 @@ export class GetHtmlUniversalRoute implements OnGet {
),
obs.pipe(
filter(__ => !!__ && !__['universal_redirect']),
map(__ => response),
map(__ => this._formatResponse(__)),
map(__ => of({ redirect: false, data: __ }))
map(__ => of({ redirect: false, data: this._formatResponse(response) }))
)
)
),
Expand All @@ -64,18 +64,19 @@ export class GetHtmlUniversalRoute implements OnGet {
obs.pipe(
filter(__ => !!__ && !!__.redirect),
tap(__ => reply.redirect(__.data)),
map(__ => 'Handle 302 redirect')
flatMap(__ => EMPTY)
),
obs.pipe(
filter(__ => !!__ && !__.redirect),
map(__ => __.data),
tap(__ => {
const rep: Response = reply(__.data.response);
const rep: Response = reply(__.response);
if (!!rep) {
rep.code(this._isValid(__.data.response) ? __.data.statusCode : 204);
rep.headers = Object.assign(__.data.headers, rep.headers);
rep.code(this._isValid(__.response) ? __.statusCode : 204);
Object.assign(rep.headers, __.headers);
}
}),
map(__ => 'Handle Angular response')
flatMap(__ => EMPTY)
)
)
)
Expand Down
4 changes: 2 additions & 2 deletions src/module/services/engine/ng.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class NgEngineService {
*
* store original function to stub it in tests
*/
private _renderModuleFactory: <T>(moduleFactory: NgModuleFactory<T>, options: {
private readonly _renderModuleFactory: <T>(moduleFactory: NgModuleFactory<T>, options: {
document?: string;
url?: string;
extraProviders?: StaticProvider[];
Expand All @@ -55,7 +55,7 @@ export class NgEngineService {
*
* store original function to stub it in tests
*/
private _provideModuleMap: (moduleMap: ModuleMap) => StaticProvider;
private readonly _provideModuleMap: (moduleMap: ModuleMap) => StaticProvider;

/**
* Service constructor
Expand Down
7 changes: 0 additions & 7 deletions test/mocha.opts

This file was deleted.

0 comments on commit 3f5a1a4

Please sign in to comment.