docs: update universal example (#48665)

This change updates the universal example to align with latest CLI changes.

PR Close #48665
This commit is contained in:
Alan Agius
2023-01-09 09:42:35 +00:00
committed by Alex Rickabaugh
parent 62becec7d9
commit 128c4a604b
3 changed files with 6 additions and 19 deletions
+5 -5
View File
@@ -1,15 +1,15 @@
import 'zone.js/node';
import { APP_BASE_HREF } from '@angular/common';
import { ngExpressEngine } from '@nguniversal/express-engine';
import * as express from 'express';
import { existsSync } from 'fs';
import { join } from 'path';
import { AppServerModule } from './src/main.server';
import { APP_BASE_HREF } from '@angular/common';
import { existsSync } from 'fs';
// The Express app is exported so that it can be used by serverless Functions.
export function app() {
export function app(): express.Express {
const server = express();
const distFolder = join(process.cwd(), 'dist/browser');
const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index';
@@ -48,8 +48,8 @@ export function app() {
return server;
}
function run() {
const port = process.env.PORT || 4000;
function run(): void {
const port = process.env['PORT'] || 4000;
// Start up the Node server
const server = app();
@@ -1,9 +1 @@
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
export { AppServerModule } from './app/app.server.module';
@@ -2,14 +2,9 @@
"extends": "./tsconfig.app.json",
"compilerOptions": {
"outDir": "./out-tsc/app-server",
"module": "commonjs",
"types": ["node"]
},
"files": [
"src/main.server.ts",
"server.ts"
],
"angularCompilerOptions": {
"entryModule": "./src/app/app.server.module#AppServerModule"
}
]
}