mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-01 11:28:13 +03:00
Update config to use mongo connection urls
This commit is contained in:
Vendored
+2
-1
@@ -1,7 +1,8 @@
|
||||
// Config file that the CI deployment uses. This is moved to $pwd/conf.json5 before CI tests are ran.
|
||||
|
||||
{
|
||||
MONGO_BASE_URL: "127.0.0.1",
|
||||
MONGO_CONNECTION_URL: "127.0.0.1:27017",
|
||||
MONGO_DATABASE_NAME: "testingdb",
|
||||
LOG_LEVEL: "info",
|
||||
CAPTCHA_SECRET_KEY: "unused",
|
||||
SESSION_SECRET: "unused",
|
||||
|
||||
Vendored
+4
-9
@@ -27,16 +27,13 @@ import {
|
||||
ImportLockDocument,
|
||||
} from "tachi-common";
|
||||
import monk from "monk";
|
||||
import { MONGO_BASE_URL } from "../../lib/setup/config";
|
||||
import { MONGO_CONNECTION_URL, MONGO_DATABASE_NAME } from "../../lib/setup/config";
|
||||
import CreateLogCtx from "../../lib/logger/logger";
|
||||
import { OrphanScoreDocument } from "../../lib/score-import/import-types/common/types";
|
||||
|
||||
const logger = CreateLogCtx(__filename);
|
||||
|
||||
/* istanbul ignore next */
|
||||
const base = MONGO_BASE_URL ?? "127.0.0.1";
|
||||
|
||||
let dbName = "ktblackdb";
|
||||
let dbName = MONGO_DATABASE_NAME;
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (process.env.NODE_ENV === "test") {
|
||||
@@ -47,16 +44,14 @@ if (process.env.NODE_ENV === "test") {
|
||||
}
|
||||
}
|
||||
|
||||
const url = `mongodb://${base}:27017/${dbName}`;
|
||||
|
||||
let dbtime: [number, number] = [0, 0];
|
||||
/* istanbul ignore next */
|
||||
if (process.env.NODE_ENV !== "test") {
|
||||
logger.info(`Connecting to database ${url}...`);
|
||||
logger.info(`Connecting to database ${MONGO_CONNECTION_URL}/${dbName}...`);
|
||||
dbtime = process.hrtime();
|
||||
}
|
||||
|
||||
export const monkDB = monk(url);
|
||||
export const monkDB = monk(`${MONGO_CONNECTION_URL}/${dbName}`);
|
||||
|
||||
/* istanbul ignore next */
|
||||
monkDB
|
||||
|
||||
@@ -26,7 +26,8 @@ function isValidURL(self: unknown) {
|
||||
}
|
||||
|
||||
export interface TachiConfig {
|
||||
MONGO_BASE_URL: string;
|
||||
MONGO_CONNECTION_URL: string;
|
||||
MONGO_DATABASE_NAME: string;
|
||||
LOG_LEVEL: "debug" | "verbose" | "info" | "warn" | "error" | "severe" | "crit";
|
||||
CAPTCHA_SECRET_KEY: string;
|
||||
SESSION_SECRET: string;
|
||||
@@ -44,7 +45,8 @@ export interface TachiConfig {
|
||||
}
|
||||
|
||||
const err = p(config, {
|
||||
MONGO_BASE_URL: "string",
|
||||
MONGO_CONNECTION_URL: "string",
|
||||
MONGO_DATABASE_NAME: "string",
|
||||
LOG_LEVEL: p.isIn("debug", "verbose", "info", "warn", "error", "severe", "crit"),
|
||||
CAPTCHA_SECRET_KEY: "string",
|
||||
SESSION_SECRET: "string",
|
||||
@@ -98,7 +100,8 @@ if (config.TYPE === "ktchi") {
|
||||
|
||||
const tachiConfig = config as TachiConfig;
|
||||
|
||||
export const MONGO_BASE_URL = tachiConfig.MONGO_BASE_URL;
|
||||
export const MONGO_CONNECTION_URL = tachiConfig.MONGO_CONNECTION_URL;
|
||||
export const MONGO_DATABASE_NAME = tachiConfig.MONGO_DATABASE_NAME;
|
||||
export const LOG_LEVEL = tachiConfig.LOG_LEVEL;
|
||||
export const SESSION_SECRET = tachiConfig.SESSION_SECRET;
|
||||
export const CAPTCHA_SECRET_KEY = tachiConfig.CAPTCHA_SECRET_KEY;
|
||||
|
||||
Reference in New Issue
Block a user