Skip to content

Commit

Permalink
chore: configureCDN
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego committed Dec 17, 2024
1 parent 769aa36 commit 621797f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
3 changes: 3 additions & 0 deletions apps/meteor/server/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import './tracing';
import './models/startup';

/**
* ./settings uses top level await, in theory the settings creation
* and the startup should be done in parallel
Expand All @@ -11,6 +12,7 @@ import { configureLogLevel } from './configureLogLevel';
import { registerServices } from './services/startup';
import { startup } from './startup';
import { configureBoilerplate } from './startup/configureBoilerplate';
import { configureCDN } from './startup/configureCDN';
import { configureDirectReply } from './startup/configureDirectReply';
import { configureIRC } from './startup/configureIRC';
import { configureFederation } from './startup/settings';
Expand Down Expand Up @@ -40,6 +42,7 @@ await Promise.all([configureLoginServices(), startFederationService()]);

await Promise.all([
configureAssets(settings),
configureCDN(settings),
configurePushNotifications(settings),
configureBoilerplate(settings),
configureDirectReply(settings),
Expand Down
32 changes: 32 additions & 0 deletions apps/meteor/server/startup/configureCDN.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { WebAppInternals } from 'meteor/webapp';

import type { ICachedSettings } from '../../app/settings/server/CachedSettings';

export async function configureCDN(settings: ICachedSettings): Promise<void> {
settings.change<string>('CDN_PREFIX', (value) => {
const useForAll = settings.get('CDN_PREFIX_ALL');
if (value && useForAll) {
WebAppInternals.setBundledJsCssPrefix(value);
}
});

settings.change<string>('CDN_JSCSS_PREFIX', (value) => {
const useForAll = settings.get('CDN_PREFIX_ALL');
if (value && typeof value === 'string' && value.trim() && !useForAll) {
WebAppInternals.setBundledJsCssPrefix(value);
}
});

const cdnValue = settings.get('CDN_PREFIX');
const useForAll = settings.get('CDN_PREFIX_ALL');
const cdnJsCss = settings.get('CDN_JSCSS_PREFIX');
if (cdnValue && typeof cdnValue === 'string' && cdnValue.trim()) {
if (useForAll) {
WebAppInternals.setBundledJsCssPrefix(cdnValue);
return;
}
if (cdnJsCss && typeof cdnJsCss === 'string' && cdnJsCss.trim()) {
WebAppInternals.setBundledJsCssPrefix(cdnJsCss);
}
}
}
35 changes: 0 additions & 35 deletions apps/meteor/server/startup/settingsOnLoadCdnPrefix.js

This file was deleted.

0 comments on commit 621797f

Please sign in to comment.