Optimizing for Docker Container
This commit is contained in:
112
src/config.ts
112
src/config.ts
@ -1,44 +1,70 @@
|
||||
export interface DatabaseConfig {
|
||||
host: string
|
||||
database: string
|
||||
}
|
||||
|
||||
export interface WebConfig {
|
||||
port: string
|
||||
secure: "true" | "false" | undefined
|
||||
}
|
||||
|
||||
export interface CoreConfig {
|
||||
name: string
|
||||
url: string
|
||||
dev: string
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
core: CoreConfig
|
||||
database: DatabaseConfig
|
||||
web: WebConfig
|
||||
dev: boolean
|
||||
logging: {
|
||||
server: string;
|
||||
appid: string;
|
||||
token: string;
|
||||
} | undefined
|
||||
}
|
||||
|
||||
import * as ini from "ini";
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
import * as dotenv from "dotenv";
|
||||
import { Logging } from "@hibas123/nodelogging";
|
||||
dotenv.config();
|
||||
|
||||
const config = ini.parse(readFileSync("./config.ini").toString()) as Config;
|
||||
|
||||
if (config.core.dev) config.dev = Boolean(config.core.dev);
|
||||
if (process.env.DEV === "true")
|
||||
config.dev = true;
|
||||
if (config.dev)
|
||||
Logging.warning("DEV mode active. This can cause major performance issues, data loss and vulnerabilities! ")
|
||||
|
||||
import { parse } from "@hibas123/config";
|
||||
import { Logging } from "@hibas123/nodelogging";
|
||||
import * as dotenv from "dotenv";
|
||||
import { readFileSync } from "fs";
|
||||
import * as ini from "ini";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
export interface DatabaseConfig {
|
||||
host: string
|
||||
database: string
|
||||
}
|
||||
|
||||
export interface WebConfig {
|
||||
port: string
|
||||
secure: "true" | "false" | undefined
|
||||
}
|
||||
|
||||
export interface CoreConfig {
|
||||
name: string
|
||||
url: string
|
||||
dev: boolean
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
core: CoreConfig
|
||||
database: DatabaseConfig
|
||||
web: WebConfig
|
||||
}
|
||||
|
||||
const config = parse({
|
||||
core: {
|
||||
dev: {
|
||||
default: false,
|
||||
type: Boolean
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
default: "Open Auth"
|
||||
},
|
||||
url: String
|
||||
},
|
||||
database: {
|
||||
database: {
|
||||
type: String,
|
||||
default: "openauth"
|
||||
},
|
||||
host: {
|
||||
type: String,
|
||||
default: "localhost"
|
||||
}
|
||||
},
|
||||
web: {
|
||||
port: {
|
||||
type: Number,
|
||||
default: 3004
|
||||
},
|
||||
secure: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
}
|
||||
}, "config.ini") as any as Config;
|
||||
|
||||
if (process.env.DEV === "true")
|
||||
config.core.dev = true;
|
||||
if (config.core.dev)
|
||||
Logging.warning("DEV mode active. This can cause major performance issues, data loss and vulnerabilities! ")
|
||||
|
||||
export default config;
|
Reference in New Issue
Block a user