mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
Merge remote-tracking branch 'origin/main' into disable-inline-css
This commit is contained in:
62
server.ts
62
server.ts
@@ -48,7 +48,7 @@ import { hasNoValue, hasValue } from './src/app/shared/empty.util';
|
||||
|
||||
import { UIServerConfig } from './src/config/ui-server-config.interface';
|
||||
|
||||
import { ServerAppModule } from './src/main.server';
|
||||
import bootstrap from './src/main.server';
|
||||
|
||||
import { buildAppConfig } from './src/config/config.server';
|
||||
import { APP_CONFIG, AppConfig } from './src/config/app-config.interface';
|
||||
@@ -130,7 +130,7 @@ export function app() {
|
||||
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
|
||||
server.engine('html', (_, options, callback) =>
|
||||
ngExpressEngine({
|
||||
bootstrap: ServerAppModule,
|
||||
bootstrap,
|
||||
inlineCriticalCss: environment.universal.inlineCriticalCss,
|
||||
providers: [
|
||||
{
|
||||
@@ -143,10 +143,10 @@ export function app() {
|
||||
},
|
||||
{
|
||||
provide: APP_CONFIG,
|
||||
useValue: environment
|
||||
}
|
||||
]
|
||||
})(_, (options as any), callback)
|
||||
useValue: environment,
|
||||
},
|
||||
],
|
||||
})(_, (options as any), callback),
|
||||
);
|
||||
|
||||
server.engine('ejs', ejs.renderFile);
|
||||
@@ -163,7 +163,7 @@ export function app() {
|
||||
server.get('/robots.txt', (req, res) => {
|
||||
res.setHeader('content-type', 'text/plain');
|
||||
res.render('assets/robots.txt.ejs', {
|
||||
'origin': req.protocol + '://' + req.headers.host
|
||||
'origin': req.protocol + '://' + req.headers.host,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -178,7 +178,7 @@ export function app() {
|
||||
router.use('/sitemap**', createProxyMiddleware({
|
||||
target: `${environment.rest.baseUrl}/sitemaps`,
|
||||
pathRewrite: path => path.replace(environment.ui.nameSpace, '/'),
|
||||
changeOrigin: true
|
||||
changeOrigin: true,
|
||||
}));
|
||||
|
||||
/**
|
||||
@@ -187,7 +187,7 @@ export function app() {
|
||||
router.use('/signposting**', createProxyMiddleware({
|
||||
target: `${environment.rest.baseUrl}`,
|
||||
pathRewrite: path => path.replace(environment.ui.nameSpace, '/'),
|
||||
changeOrigin: true
|
||||
changeOrigin: true,
|
||||
}));
|
||||
|
||||
/**
|
||||
@@ -198,7 +198,7 @@ export function app() {
|
||||
const RateLimit = require('express-rate-limit');
|
||||
const limiter = new RateLimit({
|
||||
windowMs: (environment.ui as UIServerConfig).rateLimiter.windowMs,
|
||||
max: (environment.ui as UIServerConfig).rateLimiter.max
|
||||
max: (environment.ui as UIServerConfig).rateLimiter.max,
|
||||
});
|
||||
server.use(limiter);
|
||||
}
|
||||
@@ -326,7 +326,7 @@ function initCache() {
|
||||
botCache = new LRU( {
|
||||
max: environment.cache.serverSide.botCache.max,
|
||||
ttl: environment.cache.serverSide.botCache.timeToLive,
|
||||
allowStale: environment.cache.serverSide.botCache.allowStale
|
||||
allowStale: environment.cache.serverSide.botCache.allowStale,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ function initCache() {
|
||||
anonymousCache = new LRU( {
|
||||
max: environment.cache.serverSide.anonymousCache.max,
|
||||
ttl: environment.cache.serverSide.anonymousCache.timeToLive,
|
||||
allowStale: environment.cache.serverSide.anonymousCache.allowStale
|
||||
allowStale: environment.cache.serverSide.anonymousCache.allowStale,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -416,7 +416,7 @@ function checkCacheForRequest(cacheName: string, cache: LRU<string, any>, req, r
|
||||
const key = getCacheKey(req);
|
||||
|
||||
// Check if this page is in our cache
|
||||
let cachedCopy = cache.get(key);
|
||||
const cachedCopy = cache.get(key);
|
||||
if (cachedCopy) {
|
||||
if (environment.cache.serverSide.debug) { console.log(`CACHE HIT FOR ${key} in ${cacheName} cache`); }
|
||||
|
||||
@@ -530,20 +530,20 @@ function serverStarted() {
|
||||
function createHttpsServer(keys) {
|
||||
const listener = createServer({
|
||||
key: keys.serviceKey,
|
||||
cert: keys.certificate
|
||||
cert: keys.certificate,
|
||||
}, app).listen(environment.ui.port, environment.ui.host, () => {
|
||||
serverStarted();
|
||||
});
|
||||
|
||||
// Graceful shutdown when signalled
|
||||
const terminator = createHttpTerminator({server: listener});
|
||||
const terminator = createHttpTerminator({ server: listener });
|
||||
process.on('SIGINT', () => {
|
||||
void (async ()=> {
|
||||
console.debug('Closing HTTPS server on signal');
|
||||
await terminator.terminate().catch(e => { console.error(e); });
|
||||
console.debug('HTTPS server closed');
|
||||
})();
|
||||
});
|
||||
void (async ()=> {
|
||||
console.debug('Closing HTTPS server on signal');
|
||||
await terminator.terminate().catch(e => { console.error(e); });
|
||||
console.debug('HTTPS server closed');
|
||||
})();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -560,14 +560,14 @@ function run() {
|
||||
});
|
||||
|
||||
// Graceful shutdown when signalled
|
||||
const terminator = createHttpTerminator({server: listener});
|
||||
const terminator = createHttpTerminator({ server: listener });
|
||||
process.on('SIGINT', () => {
|
||||
void (async () => {
|
||||
console.debug('Closing HTTP server on signal');
|
||||
await terminator.terminate().catch(e => { console.error(e); });
|
||||
console.debug('HTTP server closed.');return undefined;
|
||||
})();
|
||||
});
|
||||
void (async () => {
|
||||
console.debug('Closing HTTP server on signal');
|
||||
await terminator.terminate().catch(e => { console.error(e); });
|
||||
console.debug('HTTP server closed.');return undefined;
|
||||
})();
|
||||
});
|
||||
}
|
||||
|
||||
function start() {
|
||||
@@ -598,7 +598,7 @@ function start() {
|
||||
if (serviceKey && certificate) {
|
||||
createHttpsServer({
|
||||
serviceKey: serviceKey,
|
||||
certificate: certificate
|
||||
certificate: certificate,
|
||||
});
|
||||
} else {
|
||||
console.warn('Disabling certificate validation and proceeding with a self-signed certificate. If this is a production server, it is recommended that you configure a valid certificate instead.');
|
||||
@@ -607,7 +607,7 @@ function start() {
|
||||
|
||||
createCertificate({
|
||||
days: 1,
|
||||
selfSigned: true
|
||||
selfSigned: true,
|
||||
}, (error, keys) => {
|
||||
createHttpsServer(keys);
|
||||
});
|
||||
@@ -628,7 +628,7 @@ function healthCheck(req, res) {
|
||||
})
|
||||
.catch((error) => {
|
||||
res.status(error.response.status).send({
|
||||
error: error.message
|
||||
error: error.message,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user