Skip to content

Commit

Permalink
fix(demo): fix ssr not working with koa
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathonadams committed Sep 4, 2020
1 parent 61ce4a5 commit 29ccbb2
Show file tree
Hide file tree
Showing 64 changed files with 4,343 additions and 5,443 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
!angular.json
!package.json
!package-lock.json
!tsconfig.base.json
!tsconfig.json
!tsconfig.server.json
!docker/nginx.conf
!apps/
Expand Down
4 changes: 2 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -1319,12 +1319,12 @@
"apps/demo/demo-web/src/styles.scss",
{
"input": "styles/theme-default.scss",
"lazy": true,
"inject": false,
"bundleName": "theme-default"
},
{
"input": "styles/theme-default-dark.scss",
"lazy": true,
"inject": false,
"bundleName": "theme-default-dark"
}
],
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/demo-web-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["testcafe", "node"]
},
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/demo-web-functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import { https } from 'firebase-functions';
// @ts-ignore
import { app } from './server/main';

export const universal = https.onRequest(app());
export const universal = https.onRequest(app().callback());
2 changes: 1 addition & 1 deletion apps/demo/demo-web-functions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
Expand Down
14 changes: 3 additions & 11 deletions apps/demo/demo-web/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@ import { ngKoaEngine } from '@ztp/common/universal-engine';
import Koa from 'koa';
// @ts-ignore
import serve from 'koa-static';
// @ts-ignore
import helmet from 'koa-helmet';
import { helmet } from '@ztp/server/middleware';

import { AppServerModule } from './src/main.server';

// The Koa app is exported so that it can be used by serverless Functions.
export function app() {
const server = new Koa();
const distFolder = join(process.cwd(), 'dist/apps/demo/demo-web');
// const distFolder = join(process.cwd(), 'dist/browser');
const distFolder = join(process.cwd(), 'dist/browser');
const indexFilename = existsSync(join(distFolder, 'index.original.html'))
? 'index.original.html'
: 'index.html';
const indexPath = join(distFolder, indexFilename);

// TODO -> Remove the 'unsafe-inline', limitation of angular at the moment
// TODO -> Remove the 'unsafe-inline', limitation of Angular at the moment
server.use(
helmet({
expectCt: { enforce: true },
Expand All @@ -45,12 +43,6 @@ export function app() {
'fonts.googleapis.com',
'cdnjs.cloudflare.com',
],
// 'style-src-elem': [
// `'unsafe-inline'`,
// `'self'`,
// 'fonts.googleapis.com',
// 'cdnjs.cloudflare.com',
// ],
'font-src': ['fonts.gstatic.com'],
},
},
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/demo-web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion apps/server/lambda/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"strictPropertyInitialization": false,
"module": "commonjs",
Expand Down
2 changes: 1 addition & 1 deletion apps/todos/todos-web-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["testcafe", "node"]
},
Expand Down
8 changes: 5 additions & 3 deletions apps/todos/todos-web/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ if (environment.production) {
enableProdMode();
}

platformBrowserDynamic()
.bootstrapModule(AppModule)
.catch((err) => console.error(err));
document.addEventListener('DOMContentLoaded', () => {
platformBrowserDynamic()
.bootstrapModule(AppModule)
.catch((err) => console.error(err));
});
2 changes: 1 addition & 1 deletion apps/todos/todos-web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion docker/server.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ RUN mkdir dist


# Copy all files required to build the projects
COPY --chown=node:node angular.json tsconfig.base.json tsconfig.server.json ./
COPY --chown=node:node angular.json tsconfig.json tsconfig.server.json ./

# Copy all src files
COPY --chown=node:node apps/$PROJECT_DIRECTORY/ ./apps/$PROJECT_DIRECTORY
Expand Down
2 changes: 1 addition & 1 deletion libs/common/animations/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/auth/components/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/auth/data-access/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/data-access/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<mat-label>{{ field.label }}</mat-label>
<input
matInput
[type]="field.inputType"
[type]="field.inputType ? field.inputType : 'text'"
[autocomplete]="field.autocomplete ? field.autocomplete : 'off'"
[formControlName]="field.name"
/>
Expand Down
2 changes: 1 addition & 1 deletion libs/common/dynamic-form-material-components/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/dynamic-form/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/dynamic-module-loading/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/form-builder/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/grid/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/router/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/side-nav/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/toolbar-menu/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/ui/buttons/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/ui/card/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/ui/layouts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/ui/toolbar/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/universal-engine/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"files": [],
"include": [],
"references": [
Expand Down
2 changes: 1 addition & 1 deletion libs/common/utils/media-query/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/utils/notifications/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/utils/overlay/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/utils/service-worker/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/utils/storage/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/common/utils/theme/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/demo/data-access/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/demo/dynamic-form/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/demo/examples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/demo/feature-shell/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/demo/form-builder/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/demo/guides/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/demo/lazy-load-scrolling/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/demo/secure-todos/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/demo/start-your-own/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/demo/theming/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
2 changes: 1 addition & 1 deletion libs/demo/utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"types": ["node", "jest"]
},
Expand Down
1 change: 1 addition & 0 deletions libs/server/middleware/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { setupGlobalMiddleware } from './lib/global.middleware';
export { errorHandler } from './lib/err-handler';
export { helmet } from './lib/helmet';
Loading

0 comments on commit 29ccbb2

Please sign in to comment.