11import {
22 AngularNodeAppEngine ,
33 createNodeRequestHandler ,
4+ isMainModule ,
45 writeResponseToNodeResponse ,
56} from '@angular/ssr/node' ;
67import express from 'express' ;
@@ -10,7 +11,7 @@ import { fileURLToPath } from 'node:url';
1011const serverDistFolder = dirname ( fileURLToPath ( import . meta. url ) ) ;
1112const browserDistFolder = resolve ( serverDistFolder , '../browser' ) ;
1213
13- const app = express ( ) ;
14+ export const app = express ( ) ;
1415const angularApp = new AngularNodeAppEngine ( ) ;
1516
1617/**
@@ -52,12 +53,12 @@ app.use('/**', (req, res, next) => {
5253 * Start the server if this module is the main entry point.
5354 * The server listens on the port defined by the `PORT` environment variable, or defaults to 4000.
5455 */
55- // if (isMainModule(import.meta.url)) {
56- // const port = process.env['PORT'] || 4000;
57- // app.listen(port, () => {
58- // console.log(`Node Express server listening on http://localhost:${port}`);
59- // });
60- // }
56+ if ( isMainModule ( import . meta. url ) ) {
57+ const port = process . env [ 'PORT' ] || 4000 ;
58+ app . listen ( port , ( ) => {
59+ console . log ( `Node Express server listening on http://localhost:${ port } ` ) ;
60+ } ) ;
61+ }
6162
6263/**
6364 * Request handler used by the Angular CLI (for dev-server and during build) or Firebase Cloud Functions.
0 commit comments