More refactoring
This commit is contained in:
parent
c2726898e5
commit
6505aa2f5e
4 changed files with 177 additions and 129 deletions
|
|
@ -1,9 +1,9 @@
|
|||
import clone from 'clone';
|
||||
|
||||
const DEFAULT_TRUSTED_PROXIES = [
|
||||
const DEFAULT_TRUSTED_PROXIES = Object.freeze([
|
||||
'127.0.0.1',
|
||||
'::1'
|
||||
];
|
||||
]);
|
||||
|
||||
export default class WebConfiguration {
|
||||
constructor(config) {
|
||||
|
|
@ -15,7 +15,31 @@ export default class WebConfiguration {
|
|||
}
|
||||
|
||||
getTrustedProxies() {
|
||||
return DEFAULT_TRUSTED_PROXIES.slice();
|
||||
return DEFAULT_TRUSTED_PROXIES;
|
||||
}
|
||||
|
||||
getCookieSecret() {
|
||||
return this.config.authCookie.cookieSecret;
|
||||
}
|
||||
|
||||
getCookieDomain() {
|
||||
return this.config.authCookie.cookieDomain;
|
||||
}
|
||||
|
||||
getEnableGzip() {
|
||||
return this.config.gzip.enabled;
|
||||
}
|
||||
|
||||
getGzipThreshold() {
|
||||
return this.config.gzip.threshold;
|
||||
}
|
||||
|
||||
getEnableMinification() {
|
||||
return this.config.enableMinification;
|
||||
}
|
||||
|
||||
getCacheTTL() {
|
||||
return this.config.cacheTTL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -32,5 +56,19 @@ WebConfiguration.fromOldConfig = function (oldConfig) {
|
|||
});
|
||||
});
|
||||
|
||||
config.gzip = {
|
||||
enabled: oldConfig.get('http.gzip'),
|
||||
threshold: oldConfig.get('http.gzip-threshold')
|
||||
};
|
||||
|
||||
config.authCookie = {
|
||||
cookieSecret: oldConfig.get('http.cookie-secret'),
|
||||
cookieDomain: oldConfig.get('http.root-domain-dotted')
|
||||
};
|
||||
|
||||
config.enableMinification = oldConfig.get('http.minify');
|
||||
|
||||
config.cacheTTL = oldConfig.get('http.max-age');
|
||||
|
||||
return new WebConfiguration(config);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue