Compare commits
6 Commits
angular-18
...
master
Author | SHA1 | Date |
---|---|---|
Konstantina Galouni | 4178d28732 | |
Konstantina Galouni | af39ffc3ca | |
Konstantina Galouni | b1fbb7d21b | |
Konstantina Galouni | f9f87fbbc9 | |
Konstantina Galouni | b15dac68d8 | |
Konstantina Galouni | edc6425d85 |
|
@ -1,6 +1,6 @@
|
||||||
# Aggregator
|
# Aggregator
|
||||||
|
|
||||||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.3.10 and has been updated to 18.1.0.
|
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.3.10 and has been updated to 11.2.14.
|
||||||
|
|
||||||
## Install packages
|
## Install packages
|
||||||
|
|
||||||
|
|
10
angular.json
10
angular.json
|
@ -203,18 +203,18 @@
|
||||||
"serve": {
|
"serve": {
|
||||||
"builder": "@angular-devkit/build-angular:dev-server",
|
"builder": "@angular-devkit/build-angular:dev-server",
|
||||||
"options": {
|
"options": {
|
||||||
"buildTarget": "aggregator:build"
|
"browserTarget": "aggregator:build"
|
||||||
},
|
},
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"production": {
|
"production": {
|
||||||
"buildTarget": "aggregator:build:production"
|
"browserTarget": "aggregator:build:production"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extract-i18n": {
|
"extract-i18n": {
|
||||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||||
"options": {
|
"options": {
|
||||||
"buildTarget": "aggregator:build"
|
"browserTarget": "aggregator:build"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
|
@ -287,7 +287,7 @@
|
||||||
"defaultConfiguration": ""
|
"defaultConfiguration": ""
|
||||||
},
|
},
|
||||||
"serve-ssr": {
|
"serve-ssr": {
|
||||||
"builder": "@angular-devkit/build-angular:ssr-dev-server",
|
"builder": "@nguniversal/builders:ssr-dev-server",
|
||||||
"options": {
|
"options": {
|
||||||
"browserTarget": "aggregator:build",
|
"browserTarget": "aggregator:build",
|
||||||
"serverTarget": "aggregator:server"
|
"serverTarget": "aggregator:server"
|
||||||
|
@ -300,7 +300,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"prerender": {
|
"prerender": {
|
||||||
"builder": "@angular-devkit/build-angular:prerender",
|
"builder": "@nguniversal/builders:prerender",
|
||||||
"options": {
|
"options": {
|
||||||
"browserTarget": "aggregator:build:production",
|
"browserTarget": "aggregator:build:production",
|
||||||
"serverTarget": "aggregator:server:production",
|
"serverTarget": "aggregator:server:production",
|
||||||
|
|
47
package.json
47
package.json
|
@ -21,42 +21,42 @@
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^18.1.0",
|
"@angular/animations": "^16.1.8",
|
||||||
"@angular/cdk": "^18.1.0",
|
"@angular/cdk": "^16.1.7",
|
||||||
"@angular/common": "^18.1.0",
|
"@angular/common": "^16.1.8",
|
||||||
"@angular/compiler": "^18.1.0",
|
"@angular/compiler": "^16.1.8",
|
||||||
"@angular/core": "^18.1.0",
|
"@angular/core": "^16.1.8",
|
||||||
"@angular/forms": "^18.1.0",
|
"@angular/forms": "^16.1.8",
|
||||||
"@angular/localize": "^18.1.0",
|
"@angular/localize": "^16.1.8",
|
||||||
"@angular/material": "^18.1.0",
|
"@angular/material": "^16.1.7",
|
||||||
"@angular/platform-browser": "^18.1.0",
|
"@angular/platform-browser": "^16.1.8",
|
||||||
"@angular/platform-browser-dynamic": "^18.1.0",
|
"@angular/platform-browser-dynamic": "^16.1.8",
|
||||||
"@angular/platform-server": "^18.1.0",
|
"@angular/platform-server": "^16.1.8",
|
||||||
"@angular/router": "^18.1.0",
|
"@angular/router": "^16.1.8",
|
||||||
"@angular/ssr": "^18.1.0",
|
"@nguniversal/express-engine": "^16.1.1",
|
||||||
"clipboard": "^1.5.16",
|
"clipboard": "^1.5.16",
|
||||||
"core-js": "^2.5.4",
|
"core-js": "^2.5.4",
|
||||||
"express": "^4.15.2",
|
"express": "^4.15.2",
|
||||||
"jquery": "^3.4.1",
|
"jquery": "^3.4.1",
|
||||||
"ng-recaptcha-2": "^14.0.0",
|
"ng-recaptcha": "^12.0.2",
|
||||||
"prom-client": "^11.3.0",
|
"prom-client": "^11.3.0",
|
||||||
"rxjs": "^6.5.1",
|
"rxjs": "^6.5.1",
|
||||||
"ts-md5": "^1.2.0",
|
"ts-md5": "^1.2.0",
|
||||||
"tslib": "^2.0.0",
|
"tslib": "^2.0.0",
|
||||||
"uikit": "3.16.24",
|
"uikit": "3.16.24",
|
||||||
"zone.js": "~0.14.0"
|
"zone.js": "~0.13.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "^18.1.0",
|
"@angular-devkit/build-angular": "^16.1.7",
|
||||||
"@angular/cli": "^18.1.0",
|
"@angular/cli": "^16.1.7",
|
||||||
"@angular/compiler-cli": "^18.1.0",
|
"@angular/compiler-cli": "^16.1.8",
|
||||||
"@angular/language-service": "^18.1.0",
|
"@angular/language-service": "^16.1.8",
|
||||||
"@types/compression": "^1.7.0",
|
"@nguniversal/builders": "^16.1.1",
|
||||||
"@types/express": "^4.17.0",
|
"@types/express": "^4.17.0",
|
||||||
|
"@types/compression": "^1.7.0",
|
||||||
|
"@types/node": "^16.18.50",
|
||||||
"@types/jasmine": "~3.6.0",
|
"@types/jasmine": "~3.6.0",
|
||||||
"@types/jasminewd2": "~2.0.3",
|
"@types/jasminewd2": "~2.0.3",
|
||||||
"@types/node": "^18.19.1",
|
|
||||||
"browser-sync": "^3.0.0",
|
|
||||||
"codelyzer": "^6.0.0",
|
"codelyzer": "^6.0.0",
|
||||||
"jasmine-core": "~3.8.0",
|
"jasmine-core": "~3.8.0",
|
||||||
"jasmine-spec-reporter": "~5.0.0",
|
"jasmine-spec-reporter": "~5.0.0",
|
||||||
|
@ -66,8 +66,7 @@
|
||||||
"karma-jasmine": "~4.0.0",
|
"karma-jasmine": "~4.0.0",
|
||||||
"karma-jasmine-html-reporter": "^1.6.0",
|
"karma-jasmine-html-reporter": "^1.6.0",
|
||||||
"protractor": "~7.0.0",
|
"protractor": "~7.0.0",
|
||||||
"replace-in-file": "^8.2.0",
|
|
||||||
"ts-node": "~7.0.0",
|
"ts-node": "~7.0.0",
|
||||||
"typescript": "~5.4.0"
|
"typescript": "~4.9.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
130
server.ts
130
server.ts
|
@ -1,29 +1,31 @@
|
||||||
|
|
||||||
import 'zone.js/node';
|
import 'zone.js/node';
|
||||||
|
|
||||||
import { APP_BASE_HREF } from '@angular/common';
|
import { ngExpressEngine } from '@nguniversal/express-engine';
|
||||||
import { CommonEngine } from '@angular/ssr';
|
|
||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
import { existsSync } from 'node:fs';
|
import * as compression from 'compression';
|
||||||
import { join } from 'node:path';
|
import { join } from 'path';
|
||||||
import {AppServerModule} from './src/main.server';
|
|
||||||
import {REQUEST, RESPONSE} from "./src/app/openaireLibrary/utils/tokens";
|
import { AppServerModule } from './src/main.server';
|
||||||
import * as compression from "compression";
|
import { APP_BASE_HREF } from '@angular/common';
|
||||||
|
import { existsSync } from 'fs';
|
||||||
import {Prometheus} from "./prometheus";
|
import {Prometheus} from "./prometheus";
|
||||||
import {Counter} from "prom-client";
|
import {Counter} from "prom-client";
|
||||||
|
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() {
|
||||||
const server = express();
|
const server = express();
|
||||||
server.use(compression());
|
server.use(compression());
|
||||||
const distFolder = join(process.cwd(), 'dist/aggregator/browser');
|
const distFolder = join(process.cwd(), 'dist/aggregator/browser');
|
||||||
const indexHtml = existsSync(join(distFolder, 'index.original.html'))
|
const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index';
|
||||||
? join(distFolder, 'index.original.html')
|
|
||||||
: join(distFolder, 'index.html');
|
|
||||||
|
|
||||||
const prometheus: Prometheus = new Prometheus();
|
const prometheus: Prometheus = new Prometheus();
|
||||||
|
|
||||||
const commonEngine = new CommonEngine();
|
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
|
||||||
|
server.engine('html', ngExpressEngine({
|
||||||
|
bootstrap: AppServerModule,
|
||||||
|
inlineCriticalCss: false
|
||||||
|
}));
|
||||||
|
|
||||||
server.set('view engine', 'html');
|
server.set('view engine', 'html');
|
||||||
server.set('views', distFolder);
|
server.set('views', distFolder);
|
||||||
|
@ -40,81 +42,53 @@ export function app(): express.Express {
|
||||||
res.end(prometheus.register.metrics());
|
res.end(prometheus.register.metrics());
|
||||||
});
|
});
|
||||||
|
|
||||||
server.get('/health-check', async (_req, res, _next) => {
|
// All regular routes use the Universal engine
|
||||||
var uptime = process.uptime();
|
server.get('*', (req, res) => {
|
||||||
const date = new Date(uptime*1000);
|
|
||||||
const days = date.getUTCDate() - 1,
|
|
||||||
hours = date.getUTCHours(),
|
|
||||||
minutes = date.getUTCMinutes(),
|
|
||||||
seconds = date.getUTCSeconds(),
|
|
||||||
milliseconds = date.getUTCMilliseconds();
|
|
||||||
|
|
||||||
|
|
||||||
const healthcheck = {
|
|
||||||
uptime: days + " days, " + hours + " hours, " + minutes + " minutes, " + seconds + " seconds, " + milliseconds + " milliseconds",
|
|
||||||
message: 'OK',
|
|
||||||
timestamp: new Date()
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
res.send(healthcheck);
|
|
||||||
} catch (error) {
|
|
||||||
healthcheck.message = error;
|
|
||||||
res.status(503).send();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// All regular routes use the Angular engine
|
|
||||||
server.get('*', (req, res, next) => {
|
|
||||||
const { protocol, originalUrl, baseUrl, headers } = req;
|
|
||||||
|
|
||||||
let start = new Date();
|
let start = new Date();
|
||||||
let counter: Counter = prometheus.counters.get(req.path);
|
let counter: Counter = prometheus.counters.get(req.path);
|
||||||
if(counter !== undefined) {
|
if(counter !== undefined) {
|
||||||
counter.inc(1, new Date());
|
counter.inc(1, new Date());
|
||||||
|
res.render(indexHtml, {
|
||||||
commonEngine.render({
|
req, providers: [
|
||||||
bootstrap: AppServerModule,
|
{
|
||||||
inlineCriticalCss: false,
|
provide: APP_BASE_HREF,
|
||||||
documentFilePath: indexHtml,
|
useValue: req.baseUrl
|
||||||
url: `${protocol}://${headers.host}${originalUrl}`,
|
},
|
||||||
publicPath: distFolder,
|
{
|
||||||
providers: [
|
provide: REQUEST, useValue: (req)
|
||||||
{provide: APP_BASE_HREF, useValue: baseUrl},
|
},
|
||||||
{provide: REQUEST, useValue: (req)},
|
{
|
||||||
{provide: RESPONSE, useValue: (res)}
|
provide: RESPONSE, useValue: (res)
|
||||||
],
|
}
|
||||||
})
|
]
|
||||||
.then((html) => {
|
});
|
||||||
// event triggers when express is done sending response
|
// event triggers when express is done sending response
|
||||||
res.on('finish', function() {
|
res.on('finish', function() {
|
||||||
console.log(new Date().getTime() - start.getTime());
|
console.log(new Date().getTime() - start.getTime());
|
||||||
});
|
});
|
||||||
res.status(200).send(html)
|
|
||||||
})
|
|
||||||
.catch((err) => res.status(500).send('Error during SSR'))
|
|
||||||
} else {
|
} else {
|
||||||
commonEngine.render({
|
res.render(indexHtml, {
|
||||||
bootstrap: AppServerModule,
|
req, providers: [
|
||||||
inlineCriticalCss: false,
|
{
|
||||||
documentFilePath: indexHtml,
|
provide: APP_BASE_HREF,
|
||||||
url: `${protocol}://${headers.host}${originalUrl}`,
|
useValue: req.baseUrl
|
||||||
publicPath: distFolder,
|
},
|
||||||
providers: [
|
{
|
||||||
{provide: APP_BASE_HREF, useValue: baseUrl},
|
provide: REQUEST, useValue: (req)
|
||||||
{provide: REQUEST, useValue: (req)},
|
},
|
||||||
{provide: RESPONSE, useValue: (res)}
|
{
|
||||||
],
|
provide: RESPONSE, useValue: (res)
|
||||||
})
|
}
|
||||||
.then((html) => res.status(200).send(html))
|
]
|
||||||
.catch((err) => res.status(500).send('Error during SSR'))
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
function run(): void {
|
function run() {
|
||||||
const port = process.env['PORT'] || 4000;
|
const port = process.env.PORT || 4000;
|
||||||
|
|
||||||
// Start up the Node server
|
// Start up the Node server
|
||||||
const server = app();
|
const server = app();
|
||||||
|
@ -132,3 +106,5 @@ const moduleFilename = mainModule && mainModule.filename || '';
|
||||||
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
|
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export * from './src/main.server';
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {SharedModule} from './shared/shared.module';
|
||||||
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 {CommonModule} from '@angular/common';
|
import {CommonModule} from '@angular/common';
|
||||||
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
|
import {HTTP_INTERCEPTORS, HttpClientModule} from '@angular/common/http';
|
||||||
import {AppComponent} from './app.component';
|
import {AppComponent} from './app.component';
|
||||||
import {NavigationBarModule} from './openaireLibrary/sharedComponents/navigationBar.module';
|
import {NavigationBarModule} from './openaireLibrary/sharedComponents/navigationBar.module';
|
||||||
import {CookieLawModule} from './openaireLibrary/sharedComponents/cookie-law/cookie-law.module';
|
import {CookieLawModule} from './openaireLibrary/sharedComponents/cookie-law/cookie-law.module';
|
||||||
|
@ -17,32 +17,38 @@ import {ErrorInterceptorService} from "./openaireLibrary/error-interceptor.servi
|
||||||
import {DEFAULT_TIMEOUT, TimeoutInterceptor} from "./openaireLibrary/timeout-interceptor.service";
|
import {DEFAULT_TIMEOUT, TimeoutInterceptor} from "./openaireLibrary/timeout-interceptor.service";
|
||||||
import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service";
|
import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service";
|
||||||
|
|
||||||
@NgModule({ declarations: [AppComponent, OpenaireErrorPageComponent],
|
@NgModule({
|
||||||
exports: [AppComponent],
|
imports: [
|
||||||
bootstrap: [AppComponent], imports: [SharedModule,
|
SharedModule,
|
||||||
BrowserAnimationsModule,
|
BrowserAnimationsModule,
|
||||||
CommonModule,
|
CommonModule,
|
||||||
ErrorModule,
|
HttpClientModule,
|
||||||
NavigationBarModule, FeedbackModule, BottomModule,
|
ErrorModule,
|
||||||
CookieLawModule,
|
NavigationBarModule, FeedbackModule, BottomModule,
|
||||||
BrowserAnimationsModule,
|
CookieLawModule,
|
||||||
BrowserModule,
|
BrowserAnimationsModule,
|
||||||
AppRoutingModule], providers: [
|
BrowserModule,
|
||||||
ConfigurationService,
|
AppRoutingModule
|
||||||
{ provide: APP_ID, useValue: 'aggregator' },
|
],
|
||||||
{
|
declarations: [AppComponent, OpenaireErrorPageComponent],
|
||||||
provide: HTTP_INTERCEPTORS,
|
exports: [AppComponent],
|
||||||
useClass: HttpInterceptorService,
|
providers: [
|
||||||
multi: true
|
ConfigurationService,
|
||||||
},
|
{provide: APP_ID, useValue: 'aggregator'},
|
||||||
{
|
{
|
||||||
provide: HTTP_INTERCEPTORS,
|
provide: HTTP_INTERCEPTORS,
|
||||||
useClass: ErrorInterceptorService,
|
useClass: HttpInterceptorService,
|
||||||
multi: true
|
multi: true
|
||||||
},
|
},
|
||||||
[{ provide: HTTP_INTERCEPTORS, useClass: TimeoutInterceptor, multi: true }],
|
{
|
||||||
[{ provide: DEFAULT_TIMEOUT, useValue: 30000 }],
|
provide: HTTP_INTERCEPTORS,
|
||||||
provideHttpClient(withInterceptorsFromDi())
|
useClass: ErrorInterceptorService,
|
||||||
] })
|
multi: true
|
||||||
|
},
|
||||||
|
[{provide: HTTP_INTERCEPTORS, useClass: TimeoutInterceptor, multi: true}],
|
||||||
|
[{provide: DEFAULT_TIMEOUT, useValue: 30000}]
|
||||||
|
],
|
||||||
|
bootstrap: [AppComponent]
|
||||||
|
})
|
||||||
export class AppModule {
|
export class AppModule {
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,12 @@ import {OpenaireEntities} from "../openaireLibrary/utils/properties/searchFields
|
||||||
</div>
|
</div>
|
||||||
<h3>For {{openaireEntities.RESULTS | lowercase}}</h3>
|
<h3>For {{openaireEntities.RESULTS | lowercase}}</h3>
|
||||||
<div class="uk-margin-bottom">
|
<div class="uk-margin-bottom">
|
||||||
For {{openaireEntities.RESULTS | lowercase}} ({{openaireEntities.PUBLICATIONS | lowercase}}, {{openaireEntities.DATASETS | lowercase}}, {{openaireEntities.SOFTWARE | lowercase}} and {{openaireEntities.OTHER | lowercase}}) you can use the Selective Access APIs by adding the community parameter.
|
For {{openaireEntities.RESULTS | lowercase}} ({{openaireEntities.PUBLICATIONS | lowercase}}, {{openaireEntities.DATASETS | lowercase}}, {{openaireEntities.SOFTWARE | lowercase}} and {{openaireEntities.OTHER | lowercase}}) you can use the Graph API by adding the community parameter.
|
||||||
</div>
|
</div>
|
||||||
<a class="uk-display-inline-block uk-button uk-button-text"
|
<a class="uk-display-inline-block uk-button uk-button-text"
|
||||||
href="https://graph.openaire.eu/develop/api.html" target="_blank">
|
href="https://graph.openaire.eu/docs/apis/search-api/research-products" target="_blank">
|
||||||
<span class="uk-flex uk-flex-middle">
|
<span class="uk-flex uk-flex-middle">
|
||||||
<span>Selective Access APIs</span>
|
<span>Graph API</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 9c93a1e306ce7abd43e3c552a2fff0240ae2f04c
|
Subproject commit fe09fbfdcb6087e1f7e8373b654a29214adab65d
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3c9fbe2a9c606ebaec0749cf46f819020d76f6cf
|
Subproject commit 014adfe4588975e499c72b284ce7368fc2cb5d14
|
|
@ -1 +1 @@
|
||||||
Subproject commit b4d09b7cd942893c238d4152eeac1bbc822a0b13
|
Subproject commit 55765bf0829910661a55337e0e7ca7b1262b7298
|
Loading…
Reference in New Issue