[angular-18]: Update library and assets. Update node version. Use withFetch App module. Fix server.ts

This commit is contained in:
Konstantinos Triantafyllou 2024-09-23 17:36:25 +03:00
parent 349184a813
commit 142105f19a
5 changed files with 29 additions and 27 deletions

View File

@ -54,7 +54,7 @@
"@types/express": "^4.17.0", "@types/express": "^4.17.0",
"@types/jasmine": "~3.6.0", "@types/jasmine": "~3.6.0",
"@types/jasminewd2": "~2.0.3", "@types/jasminewd2": "~2.0.3",
"@types/node": "^16.18.50", "@types/node": "^18.19.1",
"browser-sync": "^3.0.0", "browser-sync": "^3.0.0",
"codelyzer": "^6.0.0", "codelyzer": "^6.0.0",
"jasmine-core": "~3.8.0", "jasmine-core": "~3.8.0",

View File

@ -1,4 +1,3 @@
import 'zone.js/node'; import 'zone.js/node';
import {APP_BASE_HREF} from '@angular/common'; import {APP_BASE_HREF} from '@angular/common';
@ -6,7 +5,8 @@ import { CommonEngine } from '@angular/ssr';
import * as express from 'express'; import * as express from 'express';
import {existsSync} from 'node:fs'; import {existsSync} from 'node:fs';
import {join} from 'node:path'; import {join} from 'node:path';
import bootstrap from './src/main.server'; import {AppServerModule} from './src/app/app.server.module';
import {REQUEST, RESPONSE} from "./src/app/openaireLibrary/utils/tokens";
// The Express app is exported so that it can be used by serverless Functions. // The Express app is exported so that it can be used by serverless Functions.
export function app(): express.Express { export function app(): express.Express {
@ -34,15 +34,19 @@ export function app(): express.Express {
commonEngine commonEngine
.render({ .render({
bootstrap, inlineCriticalCss: false,
bootstrap: AppServerModule,
documentFilePath: indexHtml, documentFilePath: indexHtml,
url: `${protocol}://${headers.host}${originalUrl}`, url: `${protocol}://${headers.host}${originalUrl}`,
publicPath: distFolder, publicPath: distFolder,
providers: [ providers: [
{ provide: APP_BASE_HREF, useValue: baseUrl },], {provide: APP_BASE_HREF, useValue: baseUrl},
{provide: REQUEST, useValue: (req)},
{provide: RESPONSE, useValue: (res)}
]
}) })
.then((html) => res.send(html)) .then((html) => res.status(200).send(html))
.catch((err) => next(err)); .catch((err) => res.status(500).send('Error during SSR'))
}); });
return server; return server;
@ -67,5 +71,3 @@ const moduleFilename = mainModule && mainModule.filename || '';
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) { if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
run(); run();
} }
export default bootstrap;

View File

@ -1,7 +1,7 @@
import {APP_ID, NgModule} from '@angular/core'; import {APP_ID, NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {CommonModule} from '@angular/common'; import {CommonModule} from '@angular/common';
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from "@angular/common/http"; import {HTTP_INTERCEPTORS, provideHttpClient, withFetch} from "@angular/common/http";
import {BrowserModule} from '@angular/platform-browser'; import {BrowserModule} from '@angular/platform-browser';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {AppComponent} from './app.component'; import {AppComponent} from './app.component';
@ -52,7 +52,7 @@ import {HelperModule} from "./openaireLibrary/utils/helper/helper.module";
}, },
[{ provide: HTTP_INTERCEPTORS, useClass: TimeoutInterceptor, multi: true }], [{ provide: HTTP_INTERCEPTORS, useClass: TimeoutInterceptor, multi: true }],
[{ provide: DEFAULT_TIMEOUT, useValue: 30000 }], [{ provide: DEFAULT_TIMEOUT, useValue: 30000 }],
provideHttpClient(withInterceptorsFromDi()) provideHttpClient(withFetch())
] }) ] })
// //
export class AppModule { export class AppModule {

@ -1 +1 @@
Subproject commit af31fcfc372e314637b24a1646db013edf19bdec Subproject commit ace2fca2e91eacd00cb7e2fcac4efa711d77a246

@ -1 +1 @@
Subproject commit eb0051dc347cdaa44476048dea9f6b61200f257f Subproject commit a88e24accc23599b43577994011e424eb693e817