-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: set number of days to store concluded events (including permane…
…ntly)
- Loading branch information
1 parent
b17238e
commit 3965dd1
Showing
3 changed files
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,9 @@ port = "3000" | |
email = "[email protected]" | ||
site_name = "gathio" | ||
is_federated = true | ||
# Events will be deleted this many days after they have ended. Set to 0 to | ||
# disable automatic deletion (old events will never be deleted). | ||
delete_after_days = 7 | ||
# If left blank, this defaults to | ||
# https://yourdomain.com/images/gathio-email-logo.gif. Set a full URL here to | ||
# change it to your own logo (or just change the file itself). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ interface GathioConfig { | |
port: string; | ||
email: string; | ||
site_name: string; | ||
delete_after_days: number | null; | ||
is_federated: boolean; | ||
email_logo_url: string; | ||
show_kofi: boolean; | ||
|
@@ -31,7 +32,7 @@ interface GathioConfig { | |
sendgrid?: { | ||
api_key: string; | ||
}; | ||
static_pages: StaticPage[]; | ||
static_pages?: StaticPage[]; | ||
} | ||
|
||
interface FrontendConfig { | ||
|
@@ -41,10 +42,27 @@ interface FrontendConfig { | |
emailLogoUrl: string; | ||
showKofi: boolean; | ||
showInstanceInformation: boolean; | ||
staticPages: StaticPage[]; | ||
staticPages?: StaticPage[]; | ||
version: string; | ||
} | ||
|
||
const defaultConfig: GathioConfig = { | ||
general: { | ||
domain: "localhost:3000", | ||
email: "[email protected]", | ||
port: "3000", | ||
site_name: "gathio", | ||
is_federated: true, | ||
delete_after_days: 7, | ||
email_logo_url: "", | ||
show_kofi: false, | ||
mail_service: "nodemailer", | ||
}, | ||
database: { | ||
mongodb_url: "mongodb://localhost:27017/gathio", | ||
}, | ||
}; | ||
|
||
export const frontendConfig = (): FrontendConfig => { | ||
const config = getConfig(); | ||
return { | ||
|
@@ -53,7 +71,7 @@ export const frontendConfig = (): FrontendConfig => { | |
isFederated: config.general.is_federated, | ||
emailLogoUrl: config.general.email_logo_url, | ||
showKofi: config.general.show_kofi, | ||
showInstanceInformation: config.static_pages?.length > 0, | ||
showInstanceInformation: !!config.static_pages?.length, | ||
staticPages: config.static_pages, | ||
version: process.env.npm_package_version || "unknown", | ||
}; | ||
|
@@ -66,7 +84,10 @@ export const getConfig = (): GathioConfig => { | |
const config = toml.parse( | ||
fs.readFileSync("./config/config.toml", "utf-8"), | ||
) as GathioConfig; | ||
return config; | ||
return { | ||
...defaultConfig, | ||
...config, | ||
}; | ||
} catch { | ||
exitWithError( | ||
"Configuration file not found! Have you renamed './config/config-example.toml' to './config/config.toml'?", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters