summaryrefslogtreecommitdiff
path: root/packages/backend/src/config.ts
diff options
context:
space:
mode:
authorSouma <101255979+5ouma@users.noreply.github.com>2024-07-14 21:33:22 +0900
committerGitHub <noreply@github.com>2024-07-14 21:33:22 +0900
commit1b84760c19a56c8928ac639d514fe28c7d01e42d (patch)
tree1dede22be08cb431bd387f61d36315acad73425c /packages/backend/src/config.ts
parentEnhance(frontend): Allow negative delay in MFM (#14200) (diff)
downloadmisskey-1b84760c19a56c8928ac639d514fe28c7d01e42d.tar.gz
misskey-1b84760c19a56c8928ac639d514fe28c7d01e42d.tar.bz2
misskey-1b84760c19a56c8928ac639d514fe28c7d01e42d.zip
enhance(backend): Load settings via environment variables (#14179)
* feat(backend): Load settings via environment variables If they're not loaded from the config file. * chore(docker): Add hints for environment variables It supports users to know about them. * docs(changelog): Add the description about this change Users can notice what's changed by this PR. * style(backend): Fix code syntax To pass the linter.
Diffstat (limited to 'packages/backend/src/config.ts')
-rw-r--r--packages/backend/src/config.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts
index 4cc27898be..3e5a1e81cd 100644
--- a/packages/backend/src/config.ts
+++ b/packages/backend/src/config.ts
@@ -23,7 +23,7 @@ type RedisOptionsSource = Partial<RedisOptions> & {
* 設定ファイルの型
*/
type Source = {
- url: string;
+ url?: string;
port?: number;
socket?: string;
chmodSocket?: string;
@@ -31,9 +31,9 @@ type Source = {
db: {
host: string;
port: number;
- db: string;
- user: string;
- pass: string;
+ db?: string;
+ user?: string;
+ pass?: string;
disableCache?: boolean;
extra?: { [x: string]: string };
};
@@ -202,13 +202,17 @@ export function loadConfig(): Config {
: { 'src/_boot_.ts': { file: 'src/_boot_.ts' } };
const config = yaml.load(fs.readFileSync(path, 'utf-8')) as Source;
- const url = tryCreateUrl(config.url);
+ const url = tryCreateUrl(config.url ?? process.env.MISSKEY_URL ?? '');
const version = meta.version;
const host = url.host;
const hostname = url.hostname;
const scheme = url.protocol.replace(/:$/, '');
const wsScheme = scheme.replace('http', 'ws');
+ const dbDb = config.db.db ?? process.env.DATABASE_DB ?? '';
+ const dbUser = config.db.user ?? process.env.DATABASE_USER ?? '';
+ const dbPass = config.db.pass ?? process.env.DATABASE_PASSWORD ?? '';
+
const externalMediaProxy = config.mediaProxy ?
config.mediaProxy.endsWith('/') ? config.mediaProxy.substring(0, config.mediaProxy.length - 1) : config.mediaProxy
: null;
@@ -231,7 +235,7 @@ export function loadConfig(): Config {
apiUrl: `${scheme}://${host}/api`,
authUrl: `${scheme}://${host}/auth`,
driveUrl: `${scheme}://${host}/files`,
- db: config.db,
+ db: { ...config.db, db: dbDb, user: dbUser, pass: dbPass },
dbReplications: config.dbReplications,
dbSlaves: config.dbSlaves,
meilisearch: config.meilisearch,