mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-14 21:31:50 +00:00
feat: always use DB_* and API_PATH_PREFIX env vars if set
This commit is contained in:
parent
e146ed6416
commit
ae03c9e03b
2 changed files with 6 additions and 21 deletions
|
@ -10,7 +10,7 @@ import { initGuildsAPI } from "./guilds/index";
|
|||
import { clientError, error, notFound } from "./responses";
|
||||
import { startBackgroundTasks } from "./tasks";
|
||||
|
||||
const apiPathPrefix = env.NODE_ENV === "production" ? env.API_PATH_PREFIX ?? "" : "/api";
|
||||
const apiPathPrefix = env.API_PATH_PREFIX || (env.NODE_ENV === "development" ? "/api" : "");
|
||||
|
||||
const app = express();
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import moment from "moment-timezone";
|
||||
import path from "path";
|
||||
import { DataSource } from "typeorm";
|
||||
import { MysqlConnectionOptions } from "typeorm/driver/mysql/MysqlConnectionOptions.js";
|
||||
import { env } from "../env";
|
||||
import { backendDir } from "../paths";
|
||||
|
||||
|
@ -10,27 +9,13 @@ moment.tz.setDefault("UTC");
|
|||
const entities = path.relative(process.cwd(), path.resolve(backendDir, "dist/data/entities/*.js"));
|
||||
const migrations = path.relative(process.cwd(), path.resolve(backendDir, "dist/migrations/*.js"));
|
||||
|
||||
type DbOpts = Pick<MysqlConnectionOptions, "host" | "port" | "username" | "password" | "database">;
|
||||
const dbOpts: DbOpts =
|
||||
env.NODE_ENV === "production"
|
||||
? {
|
||||
host: env.DB_HOST,
|
||||
port: env.DB_PORT,
|
||||
username: env.DB_USER,
|
||||
password: env.DB_PASSWORD,
|
||||
database: env.DB_DATABASE,
|
||||
}
|
||||
: {
|
||||
host: "mysql",
|
||||
port: 3306,
|
||||
username: "zeppelin",
|
||||
password: env.DEVELOPMENT_MYSQL_PASSWORD,
|
||||
database: "zeppelin",
|
||||
};
|
||||
|
||||
export const dataSource = new DataSource({
|
||||
type: "mysql",
|
||||
...dbOpts,
|
||||
host: env.DB_HOST || "mysql",
|
||||
port: env.DB_PORT || 3306,
|
||||
username: env.DB_USER || "zeppelin",
|
||||
password: env.DB_PASSWORD || env.DEVELOPMENT_MYSQL_PASSWORD,
|
||||
database: env.DB_DATABASE || "zeppelin",
|
||||
charset: "utf8mb4",
|
||||
supportBigNumbers: true,
|
||||
bigNumberStrings: true,
|
||||
|
|
Loading…
Add table
Reference in a new issue