mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-13 09:48:27 +03:00
move MongoURL to processEnv instead of json5
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
CLIENT_SECRET: "CSfoobar",
|
||||
CLIENT_ID: "CIfoobar",
|
||||
},
|
||||
MONGO_URL: "mongodb://127.0.0.1:27017",
|
||||
DISCORD: {
|
||||
TOKEN: "foobar",
|
||||
SERVER_ID: "123123123",
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
MONGO_URL="127.0.0.1:27017/tachi_bot_db"
|
||||
NODE_ENV="dev"
|
||||
+4
-1
@@ -29,7 +29,6 @@ export interface BotConfig {
|
||||
CLIENT_SECRET: string;
|
||||
CLIENT_ID: string;
|
||||
};
|
||||
MONGO_URL: string;
|
||||
DISCORD: {
|
||||
TOKEN: string;
|
||||
SERVER_ID: string;
|
||||
@@ -93,6 +92,7 @@ function ParseBotConfig(fileLoc = "conf.json5"): BotConfig {
|
||||
|
||||
export interface ProcessEnvironment {
|
||||
nodeEnv: "production" | "dev" | "staging" | "test";
|
||||
mongoUrl: string;
|
||||
}
|
||||
|
||||
function ParseEnvVars() {
|
||||
@@ -100,9 +100,11 @@ function ParseEnvVars() {
|
||||
process.env,
|
||||
{
|
||||
NODE_ENV: p.isIn("production", "dev", "staging", "test"),
|
||||
// mei implicitly reads this.
|
||||
LOG_LEVEL: p.optional(
|
||||
p.isIn("debug", "verbose", "info", "warn", "error", "severe", "crit")
|
||||
),
|
||||
MONGO_URL: "string",
|
||||
},
|
||||
{},
|
||||
{ allowExcessKeys: true }
|
||||
@@ -116,6 +118,7 @@ function ParseEnvVars() {
|
||||
|
||||
return {
|
||||
nodeEnv: process.env.NODE_ENV,
|
||||
mongoUrl: process.env.MONGO_URL,
|
||||
} as ProcessEnvironment;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { Snowflake } from "discord.js/typings/index.js";
|
||||
import monk from "monk";
|
||||
import { integer } from "tachi-common";
|
||||
import { ProcessEnv } from "../config";
|
||||
import { LoggerLayers } from "../data/data";
|
||||
import { BotConfig } from "../config";
|
||||
import { CreateLayeredLogger } from "../utils/logger";
|
||||
|
||||
const logger = CreateLayeredLogger(LoggerLayers.database);
|
||||
|
||||
logger.info(`Connecting to ${BotConfig.MONGO_URL}...`);
|
||||
logger.info(`Connecting to ${ProcessEnv.mongoUrl}...`);
|
||||
|
||||
const monkDB = monk(BotConfig.MONGO_URL);
|
||||
const monkDB = monk(ProcessEnv.mongoUrl);
|
||||
|
||||
monkDB
|
||||
.then(() => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CommandInteraction } from "discord.js";
|
||||
import { SLASH_COMMANDS } from "../commands/commands";
|
||||
import { LoggerLayers } from "../data/data";
|
||||
import { DiscordUserMapDocument } from "../database/mongo";
|
||||
import { SLASH_COMMANDS } from "../slashCommands/register";
|
||||
import { CreateLayeredLogger } from "../utils/logger";
|
||||
|
||||
const logger = CreateLayeredLogger(LoggerLayers.slashCommands);
|
||||
|
||||
Reference in New Issue
Block a user