summaryrefslogtreecommitdiff
path: root/src/lib/config.ts
diff options
context:
space:
mode:
authorGavin Mogan <git@gavinmogan.com>2025-04-25 21:43:39 -0700
committerGavin Mogan <git@gavinmogan.com>2025-04-25 21:46:07 -0700
commit14041a319cace03cfc23c0a919ed81fb141f88ce (patch)
treec87d43fe3f889bf0794caa42953781533196cb45 /src/lib/config.ts
parenta8a17443c2d070d2d23920ffff7e4a43c905698c (diff)
Refactor to have email service
* Move hbsInstance back to app * Add email and hbs to req so typescript 🎉🎉🎉 * Init Email and config once
Diffstat (limited to 'src/lib/config.ts')
-rw-r--r--src/lib/config.ts70
1 files changed, 44 insertions, 26 deletions
diff --git a/src/lib/config.ts b/src/lib/config.ts
index 003a714..6642eef 100644
--- a/src/lib/config.ts
+++ b/src/lib/config.ts
@@ -110,46 +110,46 @@ export const instanceRules = (): InstanceRule[] => {
rules.push(
config.general.show_public_event_list
? {
- text: "Public events and groups are displayed on the homepage",
- icon: "fas fa-eye",
- }
+ text: "Public events and groups are displayed on the homepage",
+ icon: "fas fa-eye",
+ }
: {
- text: "Events and groups can only be accessed by direct link",
- icon: "fas fa-eye-slash",
- },
+ text: "Events and groups can only be accessed by direct link",
+ icon: "fas fa-eye-slash",
+ },
);
rules.push(
config.general.creator_email_addresses?.length
? {
- text: "Only specific people can create events and groups",
- icon: "fas fa-user-check",
- }
+ text: "Only specific people can create events and groups",
+ icon: "fas fa-user-check",
+ }
: {
- text: "Anyone can create events and groups",
- icon: "fas fa-users",
- },
+ text: "Anyone can create events and groups",
+ icon: "fas fa-users",
+ },
);
rules.push(
config.general.delete_after_days > 0
? {
- text: `Events are automatically deleted ${config.general.delete_after_days} days after they end`,
- icon: "far fa-calendar-times",
- }
+ text: `Events are automatically deleted ${config.general.delete_after_days} days after they end`,
+ icon: "far fa-calendar-times",
+ }
: {
- text: "Events are permanent, and are never automatically deleted",
- icon: "far fa-calendar-check",
- },
+ text: "Events are permanent, and are never automatically deleted",
+ icon: "far fa-calendar-check",
+ },
);
rules.push(
config.general.is_federated
? {
- text: "This instance federates with other instances using ActivityPub",
- icon: "fas fa-globe",
- }
+ text: "This instance federates with other instances using ActivityPub",
+ icon: "fas fa-globe",
+ }
: {
- text: "This instance does not federate with other instances",
- icon: "fas fa-globe",
- },
+ text: "This instance does not federate with other instances",
+ icon: "fas fa-globe",
+ },
);
return rules;
};
@@ -179,17 +179,35 @@ export const instanceDescription = (): string => {
}
};
+let _resolvedConfig: GathioConfig | null = null;
// Attempt to load our global config. Will stop the app if the config file
// cannot be read (there's no point trying to continue!)
export const getConfig = (): GathioConfig => {
+ if (_resolvedConfig) {
+ return _resolvedConfig;
+ }
+
try {
const config = toml.parse(
fs.readFileSync("./config/config.toml", "utf-8"),
) as GathioConfig;
- return {
+ const resolvedConfig = {
...defaultConfig,
...config,
- };
+ }
+ if (process.env.CYPRESS || process.env.CI) {
+ config.general.mail_service = "none";
+ console.log(
+ "Running in Cypress or CI, not initializing email service.",
+ );
+ } else if (config.general.mail_service === "none") {
+ console.warn(
+ "You have not configured this Gathio instance to send emails! This means that event creators will not receive emails when their events are created, which means they may end up locked out of editing events. Consider setting up an email service.",
+ );
+ }
+
+ _resolvedConfig = resolvedConfig;
+ return resolvedConfig;
} catch {
exitWithError(
"Configuration file not found! Have you renamed './config/config-example.toml' to './config/config.toml'?",