mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-16 14:33:03 +00:00
Merge remote-tracking branch 'remotes/origin/master' into authentication
This commit is contained in:
@@ -4,6 +4,7 @@ import { InjectionToken } from '@angular/core';
|
||||
import { Config } from './config/config.interface';
|
||||
import { ServerConfig } from './config/server-config.interface';
|
||||
import { GlobalConfig } from './config/global-config.interface';
|
||||
import { hasValue } from './app/shared/empty.util';
|
||||
|
||||
const GLOBAL_CONFIG: InjectionToken<GlobalConfig> = new InjectionToken<GlobalConfig>('config');
|
||||
|
||||
@@ -55,6 +56,41 @@ if (envConfigFile) {
|
||||
}
|
||||
}
|
||||
|
||||
// allow to override a few important options by environment variables
|
||||
function createServerConfig(host?: string, port?: string, nameSpace?: string, ssl?: string): ServerConfig {
|
||||
const result = { host, nameSpace } as any;
|
||||
|
||||
if (hasValue(port)) {
|
||||
result.port = Number(port);
|
||||
}
|
||||
|
||||
if (hasValue(ssl)) {
|
||||
result.ssl = ssl.trim().match(/^(true|1|yes)$/i) ? true : false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const processEnv = {
|
||||
ui: createServerConfig(
|
||||
process.env.DSPACE_HOST,
|
||||
process.env.DSPACE_PORT,
|
||||
process.env.DSPACE_NAMESPACE,
|
||||
process.env.DSPACE_SSL),
|
||||
rest: createServerConfig(
|
||||
process.env.DSPACE_REST_HOST,
|
||||
process.env.DSPACE_REST_PORT,
|
||||
process.env.DSPACE_REST_NAMESPACE,
|
||||
process.env.DSPACE_REST_SSL)
|
||||
} as GlobalConfig;
|
||||
|
||||
// merge the environment variables with our configuration.
|
||||
try {
|
||||
merge(processEnv)
|
||||
} catch (e) {
|
||||
console.warn('Unable to merge environment variable into the configuration')
|
||||
}
|
||||
|
||||
buildBaseUrls();
|
||||
|
||||
// set config for whether running in production
|
||||
|
@@ -21,8 +21,6 @@ import { ENV_CONFIG } from './config';
|
||||
export function startServer(bootstrap: Type<{}> | NgModuleFactory<{}>) {
|
||||
const app = express();
|
||||
|
||||
const port = ENV_CONFIG.ui.port ? ENV_CONFIG.ui.port : 80;
|
||||
|
||||
if (ENV_CONFIG.production) {
|
||||
enableProdMode();
|
||||
app.use(compression());
|
||||
@@ -90,7 +88,7 @@ export function startServer(bootstrap: Type<{}> | NgModuleFactory<{}>) {
|
||||
https.createServer({
|
||||
key: keys.serviceKey,
|
||||
cert: keys.certificate
|
||||
}, app).listen(port, ENV_CONFIG.ui.host, () => {
|
||||
}, app).listen(ENV_CONFIG.ui.port, ENV_CONFIG.ui.host, () => {
|
||||
serverStarted();
|
||||
});
|
||||
}
|
||||
@@ -127,7 +125,7 @@ export function startServer(bootstrap: Type<{}> | NgModuleFactory<{}>) {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
app.listen(port, ENV_CONFIG.ui.host, () => {
|
||||
app.listen(ENV_CONFIG.ui.port, ENV_CONFIG.ui.host, () => {
|
||||
serverStarted();
|
||||
});
|
||||
}}
|
||||
|
Reference in New Issue
Block a user