diff options
Diffstat (limited to 'server/src/jchat_config.erl')
-rw-r--r-- | server/src/jchat_config.erl | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/server/src/jchat_config.erl b/server/src/jchat_config.erl new file mode 100644 index 0000000..35a3436 --- /dev/null +++ b/server/src/jchat_config.erl @@ -0,0 +1,46 @@ +-module(jchat_config). + +-export([get/1, get/2, + http_port/0, api_domain/0, web_domain/0, + static_files_dir/0, cors_origins/0, + jwt_secret/0, auth_config/0, + database_config/0]). + +%% Get configuration value with optional default +get(Key) -> + application:get_env(jchat, Key). + +get(Key, Default) -> + application:get_env(jchat, Key, Default). + +%% Specific configuration getters +http_port() -> + get(http_port, 8080). + +api_domain() -> + get(api_domain, "api.jchat.localhost"). + +web_domain() -> + get(web_domain, "web.jchat.localhost"). + +static_files_dir() -> + get(static_files_dir, "../client"). + +cors_origins() -> + get(cors_origins, ["*"]). + +jwt_secret() -> + Secret = get(jwt_secret, "default-secret-change-me"), + case Secret of + "default-secret-change-me" -> + logger:warning("Using default JWT secret - change this in production!"), + Secret; + _ -> + Secret + end. + +auth_config() -> + get(auth, []). + +database_config() -> + get(database, []). |