server.ts (dspace-angular-dspace-7.0) | : | server.ts (dspace-angular-dspace-7.1) | ||
---|---|---|---|---|
skipping to change at line 44 | skipping to change at line 44 | |||
import { environment } from './src/environments/environment'; | import { environment } from './src/environments/environment'; | |||
import { createProxyMiddleware } from 'http-proxy-middleware'; | import { createProxyMiddleware } from 'http-proxy-middleware'; | |||
import { hasValue, hasNoValue } from './src/app/shared/empty.util'; | import { hasValue, hasNoValue } from './src/app/shared/empty.util'; | |||
import { APP_BASE_HREF } from '@angular/common'; | import { APP_BASE_HREF } from '@angular/common'; | |||
import { UIServerConfig } from './src/config/ui-server-config.interface'; | import { UIServerConfig } from './src/config/ui-server-config.interface'; | |||
/* | /* | |||
* Set path for the browser application's dist folder | * Set path for the browser application's dist folder | |||
*/ | */ | |||
const DIST_FOLDER = join(process.cwd(), 'dist/browser'); | const DIST_FOLDER = join(process.cwd(), 'dist/browser'); | |||
// Set path fir IIIF viewer. | ||||
const IIIF_VIEWER = join(process.cwd(), 'dist/iiif'); | ||||
const indexHtml = existsSync(join(DIST_FOLDER, 'index.html')) ? 'index.html' : ' index'; | const indexHtml = existsSync(join(DIST_FOLDER, 'index.html')) ? 'index.html' : ' index'; | |||
// * NOTE :: leave this as require() since this file is built Dynamically from w ebpack | // * NOTE :: leave this as require() since this file is built Dynamically from w ebpack | |||
const { ServerAppModule, ngExpressEngine } = require('./dist/server/main'); | const { ServerAppModule, ngExpressEngine } = require('./dist/server/main'); | |||
const cookieParser = require('cookie-parser'); | const cookieParser = require('cookie-parser'); | |||
// 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() { | export function app() { | |||
skipping to change at line 137 | skipping to change at line 139 | |||
windowMs: (environment.ui as UIServerConfig).rateLimiter.windowMs, | windowMs: (environment.ui as UIServerConfig).rateLimiter.windowMs, | |||
max: (environment.ui as UIServerConfig).rateLimiter.max | max: (environment.ui as UIServerConfig).rateLimiter.max | |||
}); | }); | |||
server.use(limiter); | server.use(limiter); | |||
} | } | |||
/* | /* | |||
* Serve static resources (images, i18n messages, …) | * Serve static resources (images, i18n messages, …) | |||
*/ | */ | |||
server.get('*.*', cacheControl, express.static(DIST_FOLDER, { index: false })) ; | server.get('*.*', cacheControl, express.static(DIST_FOLDER, { index: false })) ; | |||
/* | ||||
* Fallthrough to the IIIF viewer (must be included in the build). | ||||
*/ | ||||
server.use('/iiif', express.static(IIIF_VIEWER, {index:false})); | ||||
// Register the ngApp callback function to handle incoming requests | // Register the ngApp callback function to handle incoming requests | |||
server.get('*', ngApp); | server.get('*', ngApp); | |||
return server; | return server; | |||
} | } | |||
/* | /* | |||
* The callback function to serve server side angular | * The callback function to serve server side angular | |||
*/ | */ | |||
End of changes. 2 change blocks. | ||||
0 lines changed or deleted | 6 lines changed or added |